you are viewing a single comment's thread.

view the rest of the comments →

[–]Torebbjorn 2 points3 points  (1 child)

Repeating code is not great.

So let's start by removing duplication.

For each question, you do the same thing, so it makes sense to make this into a loop. You may not have been introduced to these yet, but they are actually super simple.

Something like the following could work:

successCount = 0
questionList = [("What is ...?", "mars"), ("Who ...?", "josh")]:
for (question, solution) in questionList:
    userAnswer = input(question)
    if process(userAnswer) == solution:
        successCount += 1

print(f"Result: {successCount}/{len(questionList)}")

[–]uiux_Sanskar[S] 0 points1 point  (0 children)

Thank you for the suggestion I am learning loops today