App 1: Your First App, a Quiz Game / Build the quiz
Lesson 4 of 10
Keep score
Make a score variable that starts at 0, and add 1 every time the player is right. Print it at the end.
Key points
- score = 0 before the questions
- score += 1 when correct
- Print the score last
score = 0
answer = input("2 + 2 = ? ")
if answer.strip() == "4":
score += 1
print(f"You scored {score}")Your turn
Add a score to your quiz and print it at the end.
Quiz · +10 XP
What does score += 1 do?
Log in to save progress and earn XP.