-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountry_management_app2.0.py
More file actions
54 lines (52 loc) · 1.48 KB
/
Country_management_app2.0.py
File metadata and controls
54 lines (52 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import sys
def view_country(country):
for x in sorted(country):
print(x,end=" ")
print()
code = input("Enter Country code:").upper()
x = country.get(code,-1)
if x != -1:
print("Country is",x[0])
print("Country Capital is",x[1])
print("Country Population is",x[2])
else:
print("Their is no country for country code",code)
def add_country(country):
code = input("Enter Country Code: ").upper()
if(code in country):
print("Code already Present")
return
list = []
list.append(input("Enter Country Name: "))
list.append(input("Enter Country Capital: "))
list.append(input("Enter Country population: "))
add = {code:list}
country.update(add)
print("{} added to the list".format(list[0]))
def del_country(country):
code = input("Enter Country Code: ").upper()
x = country.pop(code,-1)
if x == -1:
print("Country Code not Found!!")
else:
print("Delete Sucessfully!!..")
country = {"IN" : ["India","Delhi",13200000000], "US":["America","Washington",32000000000], "AU": ["Australia","Canberra",2410000000],"CA":["Canada","Ottawa",94000]}
while True:
print("SELECT AN OPTION: ")
print("View: View country names")
print("add: Add a country")
print("del: Delete a country")
print("exit: Exit the program")
choice = input().lower()
if(choice == "view"):
view_country(country)
elif(choice == "add"):
add_country(country)
elif(choice == "del"):
del_country(country)
elif(choice == "exit"):
sys.exit(0)
else:
print("Wrong Choice..!!")
print("Try Again..")
print()