Why does this not work? I initialize score and count to 0 at the start. But they cannot be used in the function? There is an error? Why is this and is there a simple solution to this?
import random
capitals = ["New Dehli","Washington DC", "Tokyo", "London", "Lisbon", "Madrid", "Paris", "Berlin", "Warsaw", "Kiev", "Moscow", "Prague", "Rome"]
countries = ["India", "USA" ,"Japan" ,"England","Portugal", "Spain", "France", "Germany", "Poland", "Ukraine", "Russia", "Czech Republic", "Italy"]
score , count = 0 , 0
play = input('Would you like to play? Yes or No: ').lower()
while play == 'yes':
def main():
index = random.randrange(0, 13)
guess = input(f"What is the capital of {countries[index]} ?: ").lower()
count += 1
if guess == capitals[index].lower():
print("You guessed correct!")
score += 1
else:
print(f"Incorrect, correct answer is {capitals[index]}.")
main()
play = input('Would you like to play again? Yes or No: ').lower()
print(f"Your guessed {score} correctly out of {count}!")
quit()