May-10-2018, 02:55 AM
Thank you so much @buran for all of your help - I can see what you mean about certain areas in my code being unecessary or useless ins ome areas, or not defined later on; and I greatly appreciate your cleaner version of code; it is easy to understand for a beginner like me, and looks much nicer.
I do have a question though, in your given code, on line 8, what does the i%2 do? I am trying to figure that out to myself but I can't come to a conclusion. Is it asking if each line is an even number?
Also, on a separate note, with two lists of questions and answers, I went ahead and made a function to print out each specific question, along with its given answer. My function definition(and following code) looks like this:
I do have a question though, in your given code, on line 8, what does the i%2 do? I am trying to figure that out to myself but I can't come to a conclusion. Is it asking if each line is an even number?
Also, on a separate note, with two lists of questions and answers, I went ahead and made a function to print out each specific question, along with its given answer. My function definition(and following code) looks like this:
def get_question(self): index = 0 for item in self.questions: answer = self.answers[index] print(item) print(answer) index +=1 quiz = Game('movies_text.txt') # change this to your file name, incl. full path #print(quiz.questions) #print(quiz.answers) print(quiz.get_question())After i tested this, it showed me each question line, with each following answer - which is great because that is what I wanted. However, how do I run this function, and only get one question + answer pair at a time? Or, how do I set this up so that the user goes through each question when they want to move on, instead of displaying every question and answer pair? Thanks so much!