python - how do i stop the while function from looping and go onto the next condition -


def guess(n): import random x = random.randint(1,1000000) while n != x:     if n < x:         print("too low, try again")            elif n > x:         print("too high, try again") if n == x :     print("congrats")     again = print(input(str("play again y/n?: ")))     if again == y:         n = print(input(str("input number 'n': ")))         print(guess(n))     elif again == n:         print("goodbye") 

how make while loops stop looping if condition matched , move onto next condition have stated. thank you!

use break statement (it terminates nearest enclosing loop), e.g.

if n < x:     print("too low, try again")        elif n > x:     print("too high, try again") else:     break 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -