我正在为游戏编写此代码,在该游戏中,向玩家显示乱序的单词列表,他们必须将列表重新放回原位。
我已经编写了代码,但是当我尝试在Repl.it中运行它时,它会滞后并且不起作用。有什么方法可以修改代码以使其更高效,运行更快或完全运行?
这是我今晚必须完成的一个项目。我尝试删除一些不必要的代码,以查看是否可以运行第一部分,但是没有用。
from random import choice
sentence1words = [ "I","upon", "once", "time", "computer","class","princples","a", "took", "science"]
sentence1 = ("once upon a time I took a computer science principles class")
for i in sentence1words:
print(*sentence1words, sep = ", ")
break
sentence = []
blankspace = ""
hmm = print("Which word comes first?" + blankspace)
guess = input()
guess2 = input()
guess3 = input()
guess4 = input()
guess5 = input()
guess6 = input()
guess7 = input()
guess8 = input()
guess9 = input()
guess10 = input()
guess11 = input()
for i in sentence1:
i= sentence1[0:4]
if guess == i:
print("Good job!")
print(*sentence1words, sep = ", ")
print("What next?", guess2)
break
elif guess != i:
print("Not quite...")
for i in sentence1:
i= sentence1[5:9]
if guess2 == i:
print("Good job!")
print(*sentence1words, sep = ", ")
print("What next?", guess3)
break
else:
print("Not quite...")
'''
for i in sentence1:
i= sentence1[10]
if guess3 == i:
print("Good job!")
print(*sentence1words, sep = ", ")
print("What next?", guess4)
break
else:
print("Not quite...")
for i in sentence1:
i= sentence1[12:16]
if guess4 == i:
print("Good job!")
print(*sentence1words, sep = ", ")
print("What next?", guess5)
break
else:
print("Not quite...")
for i in sentence1:
i= sentence1[17]
if guess5 == i:
print("Good job!")
print(*sentence1words, sep = ", ")
print("What next?", guess6)
break
else:
print("Not quite...")
for i in sentence1:
i= sentence1[18:22]
if guess6 == i:
print("Good job!")
print(*sentence1words, sep = ", ")
print("What next?", guess7)
break
else:
print("Not quite...")
(this continues on until guess11)
print("Congratulations, you have completed this round of the Descramblerr. This was your sentence:", sentence)
next= input(print("Would syou like to play the next round?"))
我希望输出为“好工作!”然后重印单词列表,然后是“下一步?”但是实际输出什么也没有。