age = 30 c = 0 #定義記數器 for i in range(10): if c < 3: guess = int(input("Plseae guess my age:")) if guess == age: print("Yes,your are right") break elif guess < age: print("It is too little") else: print("Tt is too big") else: continue_confirm = input("continue press 'yes',exit press 'no':") if continue_confirm == 'yes': c = 0 elif continue_confirm == 'no': print("see you") break else: print("Wrong words") c += 1
猜年齡,用戶輸入超過3次詢問是否繼續,共10次機會。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.