MCPcopy Index your code
hub / github.com/LinkedInLearning/learning-python-2896241 / main

Function main

Ch2 - Basics/loops_finished.py:7–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7def main():
8 x = 0
9
10 # define a while loop
11 while (x < 5):
12 print(x)
13 x = x + 1
14
15 # define a for loop
16 for x in range(5,10):
17 print (x)
18
19 # use a for loop over a collection
20 days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
21 for d in days:
22 print (d)
23
24 # use the break and continue statements
25 for x in range(5,10):
26 #if (x == 7): break
27 #if (x % 2 == 0): continue
28 print (x)
29
30 # using the enumerate() function to get index
31 days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
32 for i, d in enumerate(days):
33 print (i, d)
34
35if __name__ == "__main__":
36 main()

Callers 1

loops_finished.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected