我是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")
答案 0 :(得分:0)
最简单的方法是将它放在一个带有条件中断的True循环中:
{{amount * .(100 - discount)}}
请注意,randint(1,100)将返回1-99(含)的数字,您实际上是在询问用户猜测的方式是否为2-99。