3. 設計一個猜數字游戲
import random
number = int(random.uniform(1,10))
attempt = 0
while (attempt < 3):
m = int(input('請試着猜猜數字:'))
if m == number:
print('答對了!')
break
elif m < number:
print('你的答案更小!')
attempt += 1
else:
print('你的答案更大!')
attempt += 1
else:
print(' 你的嘗試已經結束了\n','游戲結束')