I'm not sure how to fix this in my code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I'm not sure how to fix this in my code.

guess = int(input("Please enter your 3 digit # guess")) num_guesses = 1 while (guess != secret): if too high <--- (error here) else (too low) guess = int(input("Please enter another 3 digit # guess:)") num_guesses = num_guesses + 1 print("congratulations!") print("it took you , num_guesses, tries to get right")

25th Feb 2021, 11:50 PM
LEMON _
LEMON _ - avatar
1 Answer
+ 1
guess = int(input()) while (guess != secret): if guess < high: print("too low") else: print("too high") guess = int(input()) print("guessed!") # or shorter: guess = int(input()) while (guess != secret): print("too low" if guess < secret else "too high") guess = int(input()) print("guessed!")
26th Feb 2021, 12:02 AM
visph
visph - avatar