-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path09_loops.py
More file actions
53 lines (42 loc) · 1.06 KB
/
09_loops.py
File metadata and controls
53 lines (42 loc) · 1.06 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
# Loops
# while
my_conditional = 0
while my_conditional < 10:
print(my_conditional)
my_conditional += 1
else:
print('the loop continue')
while my_conditional < 20:
print(my_conditional)
my_conditional += 1
if my_conditional == 15:
print('the loop has stoped')
break
print(my_conditional)
# For
my_list = ['sergio', 'lattke', 23, 1.70, ]
for element in my_list:
print(element)
my_tuples = ('sergio', 'lattke', 23, 1.70, 23)
for element in my_tuples:
print(element)
my_set = {'python', 'javascript', 'markdown'}
for element in my_set:
print(element)
my_dict= {'Firsname':'Sergio', 'Lastname':'Lattke', 'Age':23}
for element in my_dict:
print(element)
else:
print('the loop has done')
my_dict= {'Firsname':'Sergio', 'Lastname':'Lattke', 'Age':23}
for element in my_dict:
print(element)
if element == 'age':
break
my_dict= {'Firsname':'Sergio', 'Lastname':'Lattke', 'Age':23}
for element in my_dict:
print(element)
if element == 'age':
continue
else:
print('the loop has done')