Programming-Challenges/26 Dictionaries/exercise-01.py
2026-08-31 12:48:25 +01:00

27 lines
600 B
Python

animals = {
"cat": "meow",
"dog": "woof",
"bird": "chirp",
"fish": "swim",
"snake": "slither",
"horse": "neigh",
}
score = [0, 0] # correct, total
run = True
while run:
for i in animals:
print(f"What animal goes {animals[i]}?")
answer = input("> ")
if answer.lower().strip() == i.lower():
print(f"Correct! {i} goes {animals[i]}.")
score[0] += 1
score[1] += 1
print(f"Score: {round(score[0]/score[1]*100)}%")
if not round(score[0]/score[1]*100) < 60:
run = True
score = [0, 0]