forked from mouredev/Hello-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09_loops.py
60 lines (42 loc) · 1.15 KB
/
09_loops.py
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
55
56
57
58
59
60
# Clase 5 (31/08/22) en directo desde Twitch: https://www.twitch.tv/videos/1578036618
### Loops ###
# While
my_condition = 0
while my_condition < 10:
print(my_condition)
my_condition += 2
else: # Es opcional
print("Mi condición es mayor o igual que 10")
print("La ejecución continúa")
while my_condition < 20:
my_condition += 1
if my_condition == 15:
print("Se detiene la ejecución")
break
print(my_condition)
print("La ejecución continúa")
# For
my_list = [35, 24, 62, 52, 30, 30, 17]
for element in my_list:
print(element)
my_tuple = (35, 1.77, "Brais", "Moure", "Brais")
for element in my_tuple:
print(element)
my_set = {"Brais","Moure", 35}
for element in my_set:
print(element)
my_dict = {"Nombre":"Brais", "Apellido":"Moure", "Edad":35, 1:"Python"}
for element in my_dict:
print(element)
if element == "Edad":
break
else:
print("El bluce for para diccionario ha finalizado")
print("La ejecución continúa")
for element in my_dict:
print(element)
if element == "Edad":
continue
print("Se ejecuta")
else:
print("El bluce for para diccionario ha finalizado")