-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.py
More file actions
47 lines (34 loc) · 678 Bytes
/
loops.py
File metadata and controls
47 lines (34 loc) · 678 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
41
42
43
44
45
46
47
""""
This module practice working with loops.
while, for, in, range, break, continue
"""
students = ["Ali", "Akbar", "Hamid", "Mary", "Zahra", "Mina"]
# For Loop
for student in students:
print(student)
print("\n")
for student in students:
if student == "Hamid":
print("Found!")
break
print(student)
print("\n")
for student in students:
if student == "Hamid":
print("Found!")
continue
print(student)
print("\n")
for i in range(10):
print(i)
print("\n")
for i in range(1, 11, 2):
print(i)
print("\n")
# While Loop
count = 0
while count <= 10:
if count == 5:
break
print(count)
count += 1