import random WORD = ("python","jumble","easy","difficult","answer","continue","phone","position","position","game") print( """ 欢迎参加猜单词游戏 把字母组合成一个正确的单词 """ ) iscontinue="y" while iscontinue=="y" or iscontinue= ="Y": word = random.choice(WORDS) correct = word jumble ="" while word: position = random.randrange(len(word)) jumble += word[position] word = word[:position] + word[(position + 1):] print("乱序后单词:",jumble) guess = input("\n请你猜:") while guess != correct and guess !="": print("对不起,不正确.") guess = input("继续猜:") if guess == correct: print("真棒,你猜对了!") iscontinue=input("\n是否继续(Y/N):")哪里有错误
时间: 2023-07-06 09:34:29 浏览: 83
在第11行缩进有误,应该将print语句的缩进移动到while循环语句的下一行,即第12行。同时,在第15行和第16行的赋值运算符应该使用相同的符号,即应该改为"iscontinue == 'y'"或者改为"iscontinue = 'Y'"。以下是修改后的代码:
```python
import random
WORDS = ("python", "jumble", "easy", "difficult", "answer", "continue", "phone", "position", "position", "game")
print("欢迎参加猜单词游戏\n把字母组合成一个正确的单词")
iscontinue = "y"
while iscontinue == "y" or iscontinue == "Y":
word = random.choice(WORDS)
correct = word
jumble = ""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[:position] + word[(position + 1):]
print("乱序后单词:", jumble)
guess = input("\n请你猜:")
while guess != correct and guess != "":
print("对不起,不正确.")
guess = input("继续猜:")
if guess == correct:
print("真棒,你猜对了!")
iscontinue = input("\n是否继续(Y/N):")
```
阅读全文