-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop.py
51 lines (44 loc) · 1.23 KB
/
loop.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
i = 0;
room = ["1/1","1/2","1/3"]
#while loop
while i < 5 : #while statement is true do it
print(i ,end = " ");
i = i + 1;
print(" ");
print("while loop");
#for loop
for i in room : #do i in room number
print(i ,end = " ");
print(" ");
print("for loop");
#range
for i in range(5) : #range(5) is 0,1,2,3,4
print(i ,end = " ");
print(" ");
for i in range(1,5) : #range(1,5) is 1,2,3,4,
print(i ,end = " ");
print(" ");
for i in range(2,10,2) : #range(2,10,2) is 2,4,6,8
print(i ,end = " ");
print(" ")
#break
for i in range(10) : #stop loop if i == 5
if i == 5 :
break;
print(i ,end = " ");
print(" ")
#continue
for i in range(1,11) : #if i == 5 continue the loop
if i == 5 :
continue;
print(i ,end = " ");
print(" ")
#else with loop
names = ["Mateo", "John" , "Eric:" , "Mark" , "Rober"];
search = "John";
for n in names: #do n in name
if search == n : #if searh == n print()
print(search + ' is found in list');
break;
else :
print('Not found!'); #if not true do this