How to repeat a section of the program until the input is correct?

后端 未结 3 1606
抹茶落季
抹茶落季 2020-12-04 01:25

I want my code to be repeated until the player guesses correctly.

ghuess=input("state a number between 1-100")
if ghuess>number:
    print "         


        
3条回答
  •  生来不讨喜
    2020-12-04 01:53

    Add a while-loop there. This means you're looping the question again infinitely until you've reached a satisfactory result.

    while True:
        ghuess=input("state a number between 1-100")
        if ghuess>number:
            print "too high try again!"
        elif ghuess

提交回复
热议问题