Computer Science, asked by ashutoshsingh5452, 1 month ago

python class 12 computer science

note - without using inbuilt functions

WAP to accept and do the following on a dictionary of country:capital
a) Create
b) Add
c) Search on capital
d) Search on country​

Answers

Answered by AdityaSingh2746
1

while True:

   what = input("S for search and A to add(enter to exit): ")

   country_and_cap = {}

   if what == "A":

       country = input("Enter Country: ")

       capital = input("Enter Capital: ")

       country_and_cap[country] = capital

       print(country_and_cap[country])

   elif what == "S":

       what = input("S for search and A to add(enter to exit): ")

       capital = ""

       country = ""

       if what == "CO":

           country = input("Enter Country: ")

           for keys, values in country_and_cap:

               if country == key:

                   print(key)

       else:

           capital = input("Enter Capital: ")

           for keys, values in country_and_cap:

               if capital == values:

                   print(key)

I hope this might help

Similar questions