Advertisement
ZEdKasat

Dictionaries Practice 1

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