repl.it
@hufeigopython/

猜數字

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
set_number = 87

print('請問你想跟我玩猜數字遊戲嗎?')
play_ornot = int(input('選 1 要玩,選 0 結束:'))

if play_ornot == 1:
    guess = int(input('考考你猜數字遊戲,請輸入一個數字:'))
    if guess == 0:
        print('遊戲結束!')
    elif guess > set_number:
        print('答案比較小喔!')
    elif guess < set_number:
        print('答案比較大喔!')
    else: # else 後面是不能接條件的 
        print('恭喜,你答對了!') 

elif play_ornot == 0:
    print('結束')