Hey
I have created a small quiz to learn some Python. I would like to figure out how to make the code more effective.
My solution now would be to manually copy/paste the code one more time and change questionList[0] into questionList[1] (for each question in the quiz) and so forth.
I am sure there is a smarter way to do this.
Any tips or ideas?
In any case I would appreciate a pointer in the right direction!
.......................................................
I have created a small quiz to learn some Python. I would like to figure out how to make the code more effective.
My solution now would be to manually copy/paste the code one more time and change questionList[0] into questionList[1] (for each question in the quiz) and so forth.
I am sure there is a smarter way to do this.
Any tips or ideas?
In any case I would appreciate a pointer in the right direction!
.......................................................
print(questionList[0].question)
for i in range(3):
answer = input("Response: ")
if answer == (questionList[0].answer):
print("Correct Answer")
break
if answer != questionList[0].answer:
continue
else:
print("Wrong Answer")
print("Correct answer was:", questionList[0].answer)
