Jump to content

Raj Midha

Recommended Posts

Hello folks. I am currently learning Python programming. I have created a fill in the blanks quiz game. In this game, the user has to select a level hard, medium, easy. On the basis of teh level selected, the respective question and its answers are passed as parameters into the function, question validation, this function takes user input and sees whether is matches the question and answer input. If it does, then the answer is passed onto the function, traverse. At traverse, the blanks are filled in and the sentence is returned with missing blank filled in. This seems to work well upto filling in the fourth blank. At this stage if I get the answer wrong on the first attempt and I later answer correctly, it then prompts me to fill in the 4th again. Its acting like an infinite loop. I cant for the life of me seem to solve this!!!!

The problem lies here:

        print "wrong answer you have", tries, " attempts left"
        while tries>0:
            print "Fill in ",blanks[index], " please"
            response = raw_input()
            response = response.upper()
            if response == answers[index]:
                print "congratulations!!! "
                traverse(question, answers, index)
                tries = tries - 1
                print "wrong answer you have", tries, "attempts left"
        print "Arividechi"



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...