-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path07_dicts.py
More file actions
41 lines (29 loc) · 884 Bytes
/
07_dicts.py
File metadata and controls
41 lines (29 loc) · 884 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
34
35
36
37
38
39
40
#Dictionaries
#Es una estructura de datos que nos permite guardar parejas de claves y valores
my_dict = dict()
my_other_dict = {}
print(type(my_dict))
print(type(my_other_dict))
my_other_dict = {"Name":"Brian", "Surname":"Almada", "Age":32, 1:"Python" }
my_dict = {
"Nombre":"Brian",
"Apellido":"Almada",
"Edad":32,
"Lenguajes": {"Python", "JavaScript"},
1:"Pastelero",
2:"Programador"
}
print(my_other_dict)
print(my_dict)
print(my_dict["Nombre"])
my_dict["Nombre"] = "Alexis"
print(my_dict)
my_dict["Calle"] = "Mauricio Yadarola 2204"
print(my_dict)
print("Alexis" in my_dict) # Da False porque in busca keys no values
print("Nombre" in my_dict)
print(my_dict.items())
print(my_dict.keys())
print(my_dict.values())
my_new_dict = dict.fromkeys((my_dict)) #Fromkeys crea un diccionario nuevo con las mismas keys pero sin valores
print(my_new_dict)