-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path24.dictionary3.py
More file actions
33 lines (30 loc) · 973 Bytes
/
24.dictionary3.py
File metadata and controls
33 lines (30 loc) · 973 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
28
29
30
31
32
33
# 24. Dictionaries In Python 3
"""
# dictName.copy() and dict(dictName): are use to copy a dictionary
# A dictionary can also contain many dictionaries, this is called nested dictionaries.
# It is also possible to use the dict() constructor to make a new dictionary.
#Ex: mydict= dict(key="value").... key without "" , and (=) not (:)
"""
myd = {
"name":"omar",
"age": 23
}
print("'myd' dictionary items are:\n"+str(myd))
copydict = myd.copy()
print("copy the myd dictionary using .copy() and save it in a new var called 'copydict'")
print("'copydict' dictionary items are:\n"+str(copydict))
dict = dict(myd)
print("copy the myd dictionary using dict() and save it in a new var called 'dict'")
print("'copydict' dictionary items are:\n"+str(dict))
f = {
"first":{
"no":"one",
},
"second":{
"no":"two",
}
}
print("\nnested dictionary\n"+str(f))
#print("Create a new dictionary using dict")
#newdict = dict(a="A",b="B")
#print(newdict)