-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary.py
More file actions
23 lines (19 loc) · 807 Bytes
/
dictionary.py
File metadata and controls
23 lines (19 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Dictionary is nothing but key value pairs
d = {}
# print(type(d)) ----- o/p = <class 'dict'>
d1 ={"harry":"burger","amar":"pasta","parth":"roti"}
# print(d1["amar"]) case sensitive
d1 ={"harry":"burger","amar":"pasta","parth":"roti","harish":{"bf":"maggi","lunch":"roti","dinner":"chicken"}}
# print(d1["harish"]["dinner"])
d1["ankit"] = "junk food"
d1[345]="kabab"
# print(d1)
# del d1[345]
# print(d1)
d3 = d1 #d3,d1 act as pointers, which references d1, removing an element from d1 doesnt affect d1
d0 = d1.copy() #d0 acts as another dictionary copy of d1 with the same elements in it. d0 can now me modified without affecting d1
# print(d1.get("kabab"))
d1.update({"leena":"sandwich"})
# print(d1)
# print(d1.keys())
# print(d1.items())