Saturday, March 20, 2021

Dictionary in Python

 In this tutorial I will show you how to declare and use dictionary in Python programming.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Program Listing

print("\n")

print("\tDictionary in Python\n")
print("Select a process: A) Add Data \tB) Delete Data \tC) End")
process = ["A", "B", "C"]
selection = str(input("Enter selection: "))
dict = {}
while selection.upper() in process:
if selection.upper() == "A":
key = input("Enter Key: ")
val = input(f"Enter Value: ")
dict[key] = val
elif selection.upper() == "B":
delete = str(input("Enter Key: "))
dict.pop(delete)
elif selection.upper() == "C":
print(f"THANK YOU")
break
else:
print(f"Please enter a valid response")
continue

for x in dict:
print(f"{x}:{dict[x]}", end=' ')

print(f"\n")
print("Select a process: A) Add Data \tB) Delete Data \tC) End")
selection = str(input("Enter selection: "))

No comments:

Post a Comment