-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.py
More file actions
26 lines (19 loc) · 810 Bytes
/
loops.py
File metadata and controls
26 lines (19 loc) · 810 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
################################################################################
# TITLE: Loops in Python
# DESCRIPTION: Do something until a condition is false
################################################################################
def main():
i = 0
print('This is an example of a while loop.')
while i < 10: # Check if i is still less then 10
print(i) # print i
i += 1 # add 1 to i and
# repeat
people = ['Nick', 'Steve', 'John', 'Mary']
print('This is an example of a for loop.')
for item in people: # Output each person in the people array
print(item) # print
# repeat
if __name__ == "__main__":
# Here we start the program by calling the main method
main()