0
我是一个真正的Python新手,我将它作为GCSE在我的学校,我已被赋予完成任务。我完成了这个简单代码的所有要求,但不知道如何重复。有人能告诉我一个重复代码的简单方法吗?重复整个算法
感谢
import random
Random = random.randint(1,100)
Guess = int(input("Please guess a number between 1 and 100: "))
counter = 1
while Guess != Random:
if Guess > Random:
print("Too high")
Guess = int(input("Please guess the number: "))
else:
print("Too low")
Guess = int(input("Please guess the number: "))
counter += 1
print("Well Done:")
print("You took:",counter, "Guesses")
重复代码是什么意思?你想让游戏自动重启吗? – kalhartt
提示:您已经在使用导致代码重复的技术。你如何利用'while'来实现你的目标? – Kevin
重复它直到什么时候? – dansalmo