If I understand correctly what you're trying to do here, I think you meant something like this:
speed(0)
secret_number = 7
while True:
user_number = int(input("Guess the secret number(1-10): "))
if secret_number > user_number:
down_arrow()
elif secret_number < user_number:
up_arrow()
else:
check_mark()
break
I made three changes:
- Changed
secret_number == 7
to True
in the while
loop condition. It does the same thing because secret_number
is always equal to 7, but it's easier to understand this way.
- The
while
loop never ends because the condition is always True
. I think you'd want to exit the loop when the user guesses the number. So I added a break
in the final else
branch.
- Moved the input of
user_number
into the while
loop so that the question is asked again and again as long as the answer is wrong, instead of only once.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…