forked from bradtraversy/python_sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.py
More file actions
36 lines (25 loc) · 797 Bytes
/
Copy pathloops.py
File metadata and controls
36 lines (25 loc) · 797 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
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
people = ['Tom', 'Susan', 'Dustin', 'Michael', 'Sara']
# simple for loop (for in loop)
for person in people:
print(f'current person {person}' )
# Break
for person in people:
if person == 'Dustin':
break
print(f'current person (break) {person}' )
# Continue
for person in people:
if person == 'Dustin':
continue
print(f'current person (continue) {person}' )
# range
for i in range(len(people)):
print(f'range:: {people[i]}')
for i in range(1, 24):
print(f'custom range {i}')
count = 0
while count <= 10:
print(f'count :: {count}')
count += 1
# While loops execute a set of statements as long as a condition is true.