import random #把random模塊呼叫出來 age = random.randint(10,25)#用rand.randint制造一個亂數表 count = 0 while count < 3:#共有三次機會 n = int(input('Guess the age:'))#輸入用戶通過鍵盤敲打的資料 if n > age: print('Try smaller,你還有%s次機會'%(2-count)) count += 1 elif n < age: print('Try bigger,你還有%s次機會'%(2 - count)) count += 1 else: print('Yes,you get it') break#結束回圈 print(age)
本文首發于python黑洞網,博客園同步更新
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/180085.html
標籤:其他
