Professional Documents
Culture Documents
FALLSEM2023-24 ICSE101E ELA VL2023240106565 2023-10-05 Reference-Material-I
FALLSEM2023-24 ICSE101E ELA VL2023240106565 2023-10-05 Reference-Material-I
FALLSEM2023-24 ICSE101E ELA VL2023240106565 2023-10-05 Reference-Material-I
1 Dictionaries
Dictionaries are unordered set of key value pairs separated by commas. Unlike Lists (which are
sequence based) dictionary elements are not indexed but can be retrieved using the keys.
1
1.0.2 Adding, Editing, Removing Elements
[54]: 2
Tim
None
2
1
Tim Billy
1
Tim Billy
1
Tim Billy
id:1
name:Tim Billy
[44]: # copy
dict5 = dict4.copy()
dict5['name']='Billy John'
print(dict4)
print(dict5)
3
[41]: # remove all elements from the dictionary
print(dict1)
dict1.clear()
print(dict1) # pls note dictionary is not deleted but only emptied
print(country_specialities_dict)
dict6
print(dict6['favorite_colors'])
print(dict6['contacts']['email'])
print(dict6['nick_names'])
['Blue', 'Red']
alex@example.com
('Alexie', 'A-man')