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

后端 未结 3 1603
抹茶落季
抹茶落季 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:51

    For a solution without a break:

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

提交回复
热议问题