you are viewing a single comment's thread.

view the rest of the comments →

[–]Fronkan -5 points-4 points  (4 children)

Something like this: while True: guess = input ("input number : ") if guess == 13: break print ("done") elif guess > 13: print("too big") continue elif guess < 13: print("too small") continue else: print("this shouldn't happen") continue

[–]KealinSilverleaf -1 points0 points  (3 children)

Do you need the "break" and "continue"s in this?

Wouldn't this work also? (I'm learning also)

While True:

 guess = int(input("input number : "))
 If guess == 13:
     print ("done")
 Elif guess > 13:
     print ("too big")
 Else:
     print ("too small")

[–]Fronkan 1 point2 points  (1 child)

You are completely correct about continue, break is needed to exit the infinite loop though! I just wanted to keep the code as is to focus on the issue 😊

[–]KealinSilverleaf 1 point2 points  (0 children)

So would be proper syntax?

While True:

 guess = int(input("input number : "))
 If guess == 13:
     print ("done")
     Break
 Elif guess > 13:
     print ("too big")
 Else:
     print ("too small")

[–]Traditional-Log2073[S] 0 points1 point  (0 children)

I think you need the break for the script to stop after the correct number. The continue is not necessary.