我想要它,所以它将随机生成1-10之间的数字,用户将输入他们的猜测。然后它会输出它是对还是错,10轮后它会告诉他们他们是多么通灵。我已经完成了大部分工作,但我不能让它随机生成10个数字,而是生成1个数字,你可以只输入这个数字,如果你找到那个数字,每次都会正确
import random
score=0
random=(random.randint(1,10))
for index in range(10):
guess=int(input("Choose a number between 1 and 10:"))
if random==guess:
score+=1
print ("Correct, Next")
else:
print ("Incorrect, Next")
if score==10:
print("Final score:Super mystic")
elif score>=7:
print("Final score:Good")
elif score>=5:
print ("Final score:You need more practice")
else:
print ("Final score:Dont become a psychic")发布于 2021-02-08 20:03:04
您需要将random=(random.randint(1,10))放在for循环中,以便它在每次循环时都会发生变化:
for index in range(10):
random=(random.randint(1,10))
guess=int(input("Choose a number between 1 and 10:"))然后剩下的代码
https://stackoverflow.com/questions/66101120
复制相似问题