import random secret = random.randint(1, 30) guess = 0 tries = 0 print("我叫丁丁,我有一個祕密數字!") print("數字從1到30,你只有6次機會!") while int(guess) != secret and tries < 6: print("你猜的數字是?") guess = input() if int(guess) < secret: print("數字過小了!再猜!") elif int(guess) > secret: print("數字太大了!再猜!") tries = tries + 1 if int(guess) == secret: print("你真厲害!恭喜你猜對啦!") else: print("你猜錯6次啦,下次再玩吧!") print("個人祕密數字是:", secret)