我撰寫出來后沒達到效果且無限回圈
程式如下:(加粗部分是出錯的地方)
# 計算機隨機挑選一個單詞,告知玩家這個單詞長度
# 玩家來猜,并有5次機會問計算機
import random
# 創建一組可選的單詞
WORDS = ("python","jumble","easy","difficult","answer","xylophone")
# 隨機挑選一個單詞
word = random.choice(WORDS)
# 創建正確答案變數
correct = word
# 開始游戲
print ("""
i will tell you a(n) word's len.
you guess.
you can ask me whether a letter in this word.
you have 5 chances.
""")
print("it's len is ",len(correct))
guess = input("Your guess: ")
i = 0
while guess != correct and i <= 5:
print("That's not it")
print("You can ask me whether a letter in this word.")
help = (input('So, don\'t you want to ask me? "Yes" or "No": ')).lower
if help == 'yes':
i += 1
letter = input('The letter you guess is: ')
if letter in correct:
print('Yes,', letter, 'is in this word.')
else:
print('No,', letter, 'is not in this word.')
guess = input("please guess again: ")
else:
guess = input("please guess again: ")
if guess == correct:
print("That's it!")
if i <= 3:
print("Your grade is 10.")
elif i > 3 and i <=4:
print("Your grade is 8.")
elif i >4:
print("Your grade is 6.")
else:
print("Sorry, you don't guess it and your chance is exhausted")
print("Your grade is 1.")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/257554.html
標籤:非技術區
上一篇:請教下nvme SSD盤 creat-ns后無法找到ns的問題,有誰知道嗎
下一篇:解決編碼問題:AttributeError: 'str' object has no attribute 'sheets'
