0

I'm not really good at while loops anyone mind giving me a hand with my code?

while (guess != secret): if too high else (too low)

25th Feb 2021, 11:27 PM
Yanely Alfonso
Yanely Alfonso - avatar
3 Answers
0
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!")
25th Feb 2021, 11:35 PM
visph
visph - avatar
0
Thank you so much!
25th Feb 2021, 11:36 PM
Yanely Alfonso
Yanely Alfonso - avatar
0
just a little update (forgotten else in shortest alternative)
25th Feb 2021, 11:37 PM
visph
visph - avatar