from random import *
a = randint(1,100)
guess = 0
while True:
num = input("猜想的數字:")
guess += 1
if not num.isdigit():
print("請輸入數字")
elif int(num) < 0 or int(num) >=100:
print("輸入的數字超出了範圍!")
else:
if int(num) == a:
print("恭喜您猜對了!")
elif int(num) > a:
print("您輸入的數字大了!")
elif int(num) < a:
print("您輸入的數字小了!")
else:
print("系統發生未知錯誤,請聯繫工做人員進行處理!")git