-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary.py
More file actions
27 lines (24 loc) · 814 Bytes
/
Dictionary.py
File metadata and controls
27 lines (24 loc) · 814 Bytes
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
# #Dictionary drived
md = {
"Fast":"complate in few seconds",
"raj":"A learner",
"jay":"ram ram",
"lis":[2,3,34,54],
"nextmd":{"raj1":"is a good"}
}
# Dictionary Methods
print(md.keys()) #print key values of dictionary
print(type(md.keys()))
print(list(md.keys()))
print(list(md.values())) #print values of keys of dictionary
print(md.values())
print(md.items()) #print the(keys,values) contain of dictionary
'''Update contain of main dictionary by another dictionary'''
updatemd = {
"Ankur":"is the best friend",
"jay":"rajkumar"
}
md.update(updatemd)
print(md)
print(md["jay2"]) #throws an error as jay2 is not present in the dictionary
print(md.get("jay2")) #Returns None as jay2 is not present in the dictionary