-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathlistas.py
More file actions
54 lines (40 loc) · 1.15 KB
/
listas.py
File metadata and controls
54 lines (40 loc) · 1.15 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
# Clase 4
# Listas
lista_super = ["pan", "leche", "jamon", "jamon","galletitas"]
print(lista_super[0])
print("verifico que el tipo de dato de mi elemento en la lista es string")
print(type(lista_super[0]))
print("Y lista que tipo de dato es?")
print(type(lista_super))
print(lista_super[2])
## READ o leer
for x in range(0, len(lista_super)):
print(lista_super[x])
## Crear
lista_super.append("coca cola")
print("Agrego un elemento: ")
for x in range(0, len(lista_super)):
print(lista_super[x])
# me permite sacar elementos
item = lista_super.pop()
print(item)
# y le podemos pasar pop("pan") ?
# para que sea mas rapido
for x in range(0, len(lista_super)):
if lista_super[x] == "jamon":
print("Me encontraste en el indice: ", x)
te_encontre = False
indice = 0
while (te_encontre is False) and (indice < len(lista_super)):
if lista_super[indice] == "jamon":
te_encontre = True
print("Indice en el while: ", indice)
indice += 1
print("Se encontro?", te_encontre)
print("Indice: ", indice)
## otra forma de recorrer una lista
# es con for in
for x in lista_super:
print(type(x))
print(x)
print("FIN PROGRAMA")