Computer Science, asked by yadramsurana2753, 5 months ago

Write a program to create a dictionary to store names of States and their capitals.(upto 5 states)                2 .​

Answers

Answered by dreamrob
5

Program :

States = dict()

n = int(input("Enter number of states : "))

for i in range(n):

   State = input("Enter State : ")

   Capital = input("Enter Capital : ")

   States[State] = Capital

print("States Dictionary : ",States)

Output :

Enter number of states : 5

Enter State : Maharashtra

Enter Capital : Mumbai

Enter State : Bihar

Enter Capital : Patna

Enter State : Assam

Enter Capital : Dispur

Enter State : Goa

Enter Capital : Panaji

Enter State : Gujarat

Enter Capital : Gandhinagar

States Dictionary :  {'Bihar': 'Patna', 'Maharashtra': 'Mumbai', 'Gujarat': 'Gandhinagar', 'Goa': 'Panaji', 'Assam': 'Dispur'}

Attachments:
Similar questions