8000 completed loops · RobACurtis/Learning-Python@ca8092e · GitHub
[go: up one dir, main page]

Skip to content

Commit ca8092e

Browse files
committed
completed loops
1 parent 58a68ae commit ca8092e

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Ch2 - Basics/loops_start.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,35 @@ def main():
88
x = 0
99

1010
# TODO: define a while loop
11+
while (x < 5):
12+
print(x)
13+
x = x + 1
1114

1215

1316
# TODO: define a for loop
14-
17+
for x in range(15, 20):
18+
print(x)
1519

1620
# TODO: use a for loop over a collection
1721
days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
1822

23+
for d in days:
24+
print(d)
25+
1926

2027
# TODO: use the break and continue statements
28+
for x in range(5, 10):
29+
# if x==7:
30+
# break
31+
if x % 2 == 0:
32+
7878 continue
33+
print(x)
34+
35+
36+
# TODO: using the enumerate() function to get index
37+
for i,d in enumerate(days):
38+
print(i, d)
2139

2240

23-
# TODO: using the enumerate() function to get index
24-
25-
2641
if __name__ == "__main__":
2742
main()

0 commit comments

Comments
 (0)
0