-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8-loops.py
44 lines (27 loc) · 1004 Bytes
/
8-loops.py
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
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
# Simple Loop
# people = ['John', 'Mary', 'Anna', 'Margaret', 'Sylvia']
# for person in people:
# print('Current person is: ', person)
# Break
# people1 = ['John', 'Mary', 'Anna', 'Margaret', 'Sylvia', 'Monique']
# for child in people1:
# if child == 'Anna':
# print('Current child is: ', child)
# break
# gamers = ['John', 'Mary', 'Anna', 'Margaret', 'Sylvia', 'Monique']
# for person in gamers:
# if person == 'Caty':
# continue
# print('Current gamer is: ', person)
# Range
# gamers = ['John', 'Mary', 'Anna', 'Margaret', 'Sylvia', 'Monique']
# for i in range (len(gamers)):
# print('Current gamer: ', gamers[i])
# for i in range (0, 10):
# print ('Number ', i)
# While loops execute a set of statements as long as a condition is true.
count = 0
while count <=10:
print('Counting ', count)
count +=1