I'm a complete beginner at python and I know I'm probably approaching this the wrong way but I've tried making a quiz and can't work out how to make it more concise and work with longer lists of questions and answers without having to use lots of "if" statements. Here's the code:
import random
score = 0
questions = ["In which year did Diego Maradona score a goal with his hand?\n->",
"In which sport can you win the Davis Cup?\n->",
"How many minutes is a rugby match?\n->",
"In which country were the first Olympic Games held?\n->",
"In which country is the Interlagos F1 circuit?\n->"]
answers = ["1986","tennis","80","greece","brazil"]
print("---------------------------------")
print("You are running Ben's sports quiz")
print("---------------------------------\n")
question = random.sample(range(1,6),5)
for num in question:
if num == 1:
user_answer_1 = input(questions[0])
if user_answer_1.lower() == answers[0]:
print("Correct\n")
score = score + 1
else:
print("Incorrect\n")
if num == 2:
user_answer_2 = input(questions[1])
if user_answer_2.lower() == answers[1]:
print("Correct\n")
score = score + 1
else:
print("Incorrect\n")
if num == 3:
user_answer_3 = input(questions[2])
if user_answer_3.lower() == answers[2]:
print("Correct\n")
score = score + 1
else:
print("Incorrect\n")
if num == 4:
user_answer_4 = input(questions[3])
if user_answer_4.lower() == answers[3]:
print("Correct\n")
score = score + 1
else:
print("Incorrect\n")
if num == 5:
user_answer_5 = input(questions[4])
if user_answer_5.lower() == answers[4]:
print("Correct\n")
score = score + 1
else:
print("Incorrect\n")
print("Your final score is",score,"out of 5\n")
input("Press ENTER to exit")
Any help would be greatly appreciated.