I am currently doing Udacity's introduction to programming development course. As a part of this course, I have to create a fill in the blanks game. The game is structured like this:
The user is asked to choose a level based on difficulty. Once the user decides what level he/she wants to play, the parameters: question, the answers to that question, blanks list, and an index of 0 are passed to the function Question Validation.
At the question validation function. We assess whether user input matches what is contained in the answers based on the index. For example, if I am filling in the first blank, then my answer(input) must equal that of answers[0]. If it does not then the user has 4 tries to get it right. If the user does not, the game is quit. Once the user selects the right answer, this is passed to the function traverse.
Here is the code for question validation
https://www.dropbox.com/sh/e5doud7wt2awlfo/AACoMdohawZj54RwjIWvtAKda?dl=0
The function traverse takes in as parameters:the question; the list of answers to that question; and the index as parameters. Based on this information, this function will fill in the question blanks accordingly and passes this back to the question validation for the user to then fill in the next blank. When all the blanks are filled, the program is stopped.
Here is the code for traverse
https://www.dropbox.com/s/w4cra1hah5xww9q/traversefunct.py?dl=0
I have written comments in my code that further elaborate on what I have outlined here.
Here is the complete code
https://www.dropbox.com/s/npendg2ey63e8rr/codeaquiz.py?dl=0
The code seems to work fine and does what I want it to do up until filling the 4th blank. At this point if I choose the wrong answer and then go back and choose the right answer. It acknowledges that I have chosen the right answer but then prompts for the answer again. Its an infinite loop and I cant see for the life of why it is happening here when for filling in previous blanks it was not working.
Here is a screenshot of what is happening with regards to being prompted again:
https://www.dropbox.com/s/s8sk8r19gz4ued2/Screenshot%202018-04-27%2014.13.22.png?dl=0
I cant for the life of me see why: