+ 1
i have an error in this code can anybody modify it
Country = input("enter a country : ") capitals = { "Afghanistan": "Kabul", . . .(all a to z country with capitals are here i have not mentioned all as the desciption has a limit and the code is lenghty) . . . "Zimbabwe": "Harare", } Country, capitals = c(list(capitals.items())) print(f"the capital of {Country} is {capitals}.")
4 Answers
+ 5
Pg1001
As capitals is a dictionary so use get function to get value like:
print (capitals.get(country))
+ 3
@AJ
i have tried now its working fine thanks
+ 3
The second last line isn't necessary here.
You can do this instead
print(f"the capital of {Country} is {capitals[Country]}.")
+ 2
@Simba
pls see the code now it was a lenghty code hence there is a limit on range of question