-2
由于某些原因,下面的代码不会带来任何错误,但每次都会产生相同的“拼图”(注意,一旦代码运行后,拼图将在稍后添加)任何人都可以提出可能的原因和解决方法没有指定错误,但它没有做我期望或想要的
import random
correct = 0
not_again = []
puzzle = ["SUP","SAS","FUN","IS"]
answer = ["SUP","SAS","FUN","IS"]
life = 10
print("Welcome to the labrynth")
print("You are an explorer")
print("You have entered the maze in the hope of finding the lost treasure")
print("There will be a door blocking your entrance and preceedings at which a puzzle will be presented")
print("If you get the answer correct the door will open")
print("Then another 9 puzzles arrive at which point there will be the ultimate puzzle giving you the treasure")
print("If you get it wrong you lose one of ten lives")
def puzzles():
global correct
global not_again
global puzzle
global answer
global life
print("A stone door blocks your path")
print("An inscription is on it: a riddle")
select = random.randint(1,4)
select -= 1
select = int(select)
if select in not_again:
select = random.randint(1,4)
select -= 1
for select in range(len(puzzle)):
puz = puzzle[select]
print(puz)
doesit = input("Type your answer")
if doesit == answer[select]:
print("The door opens!")
correct += 1
not_again.append(select)
print(not_again)
if correct < 10:
puzzles()
elif doesit != answer[select]:
life -= 1
not_again.append(select)
if correct < 10:
puzzles()
puzzles()
谢谢它似乎是为了 – Seb