-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary.py
More file actions
54 lines (41 loc) · 1.36 KB
/
Copy pathdictionary.py
File metadata and controls
54 lines (41 loc) · 1.36 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
# marks = {"english" : 95,"chemistry" : 98}
# information = {"tonmay" : "fer"}
# print(marks["chemistry"])
# marks["physics"] = 97##adding value
# print(marks)
# marks["physics"] = 99 #changing data value
# print(marks)
# mydict = {
# "Fast": "In a Quick Manner",
# "Turza" : "A coder",
# "Marks":[1,2,3],
# "another":{'Harry':"Player"}#another dictionary like nested
# }
# print(mydict["Fast"])
# print(mydict["Marks"])
# print(mydict["another"]["Harry"])
# #changing value:
# mydict["Marks"] = [23,2,42]#mutable,changing possible
# print(mydict["Marks"])
###########################################Method#######################################
mydict = {
"Fast": "In a Quick Manner",
"Turza" : "A coder",
"Marks":[1,2,3],
"another":{'Harry':"Player"},
1 : 2
}
print(mydict.keys()) # keys gulo print korar jnno use krte hy
print(type(mydict.keys()))
print(list(mydict.keys()))#type casting....list e banay nilam
print(mydict.values())##value gulo print krar jnno
print(mydict.items()) ##prints all value and contents of dictionary
#####update dictionary by adding key - values pair from updateDict
updateDict = {
"Lovish" : " friend",
"Ruman" : "Friend"
}
mydict.update(updateDict)
print(mydict)
print(mydict.get("harry"))#nine dekhabe
# print(mydict["harry2"]) # error dekhabe