0% found this document useful (0 votes)
9 views2 pages

Capital Cities Quiz Game Code

The document contains a Python script for a capital city quiz game where players guess the capital of randomly selected countries. The game tracks the player's score and allows them to play multiple rounds. It also saves the score to a file named 'scores.txt' after each game.

Uploaded by

medwinm00
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Capital Cities Quiz Game Code

The document contains a Python script for a capital city quiz game where players guess the capital of randomly selected countries. The game tracks the player's score and allows them to play multiple rounds. It also saves the score to a file named 'scores.txt' after each game.

Uploaded by

medwinm00
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import random

def play_game():
score = 0

capital_cities = {
"Spain": "Madrid",
"Germany": "Berlin",
"Italy": "Rome",
"Belgium": "Brussels",
"Switzerland": "Bern"
}

for i in range(len(capital_cities)):
country= [Link](list(capital_cities.keys()))
city = capital_cities[country]
capital_cities.pop(country)
choices = []

list_capital_cities = ["Mariehamn", "Tirana", "Athens",


"Pristina", "Riga", "London", "Paris", "Oslo", "Warsaw", "Lisbon",
"Bucharest", "Moscow", "Amsterdam", "Monaco"]

[Link](city)

for i in range(5):

random_county = [Link](list_capital_cities)
[Link](random_county)
list_capital_cities.remove(random_county)

[Link](choices)

answer = input(f"What is the capital choice of {country}?\n


{choices}: ")

if answer == city:
score += 1
print("Correct")
else:
print("Incorrect")

print(f"Your score is {score}")


with open("[Link]", "w") as f:
[Link](f"{score}\n")

retake = input("Do you want to play again? (yes/no): ")


if [Link]() == "yes":
play_game()
else:
pass

play_game()

You might also like