Unit 4 - Lesson 11

44.1.1. Understand the Methods in Dictionary

#write your code here
d1 = input("data1: ").split(",")
d2 = input("data2: ").split(",")
d3 = input("data3: ").split(",")
d4 = input("data4: ").split(",")
a = dict(zip(d1,d2))
print("sorted dictionary:",sorted(a.items()))
b = a.copy()
print("copy of sorted dictionary:", sorted(b.items()))
print("sorted keys of dictionary:", sorted(a.keys()))
print("sorted values of dictionary:", sorted(a.values()))
c = dict(zip(d3,d4))
d = a | c
print("sorted dictionary after updation:", sorted(d.items()))

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.