-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuiz Game.py
34 lines (30 loc) · 1.04 KB
/
Quiz Game.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from questionsmarvel import quiz as marvel_quiz
from questionsdc import quiz as dc_quiz
def check_ans(question, answer, attempts, score, quiz):
if quiz[question]['answer'].lower() == answer.lower():
print(f"Correct Answer! \nYour score is {score + 1}!")
return True
else:
print(f"Wrong Answer :( \nYou have {attempts - 1} attempts left. Try again...")
return False
score = 0
for question in marvel_quiz:
attempts = 3
while attempts > 0:
print(marvel_quiz[question]['question'])
answer = input("Enter Answer: ")
check = check_ans(question, answer, attempts, score, marvel_quiz)
if check:
score += 1
break
attempts -= 1
for question in dc_quiz:
attempts = 3
while attempts > 0:
print(dc_quiz[question]['question'])
answer = input("Enter Answer: ")
check = check_ans(question, answer, attempts, score, dc_quiz)
if check:
score += 1
break
attempts -= 1