Advertisement
Arcot

ch8 ex2

Dec 12th, 2021
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. country_capitals = {
  2.     "Australia": "Canberra",
  3.     "India": "Delhi",
  4.     "Japan": "Tokyo"
  5. }
  6.  
  7. score = 0
  8. import random
  9. while len(country_capitals):
  10.     print(f"Your current score is {score}.\n")
  11.     country = random.choice(list(country_capitals.keys()))
  12.     capital = country_capitals.pop(country)
  13.  
  14.     ans = input(f"What is the Capital of {country}: ")
  15.     if ans.lower() == capital.lower():
  16.         print("Good Job")
  17.         score += 1
  18.     else:
  19.         print(f"Nah, the capital for {country} is {capital}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement