-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop.py
87 lines (68 loc) · 1.27 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
'''# Loop
# for loops
name = 'Rupesh'
for i in name:
print(i)
if (i == "p"):
print("This is something specisl!")
colors = ["red", "green", "blue", "yellow"]
# for x in colors:
# print(x)
# if(x == "blue"):
# print("its blue color")
for color in colors:
print(color)
for i in color:
print(i)
# for k in range (5):
# print(k+1)
for k in range (1,12,3):
print(k)
# for k in range (1,2000):
# print(k)
# while loops
i = int(input("enter the value: "))
while(i <= 30):
i = int(input("enter the value:"))
print(i)
print("done with the loop")
# break and continous
for i in range(12):
print("5 X", i+1, "=", 5 * (1+i))
if(i == 10):
break
print("if case is out from loop ")
for i in range(12):
if(i == 10):
print("skip the iteration")
continue
print("5 X", i, "=", 5 * (i))
i = 0
while True:
print(i)
i = i + 1
if(i%100 == 0):
break
'''
# FOR LOOP WITH ELSE
# for loop
# for i in []:
# print(i)
# # if i == 4:
# # break
# else:
# print("sorry no i")
for i in range(6):
print(i)
if i == 4:
break
else:
print("sorry no i")
i = 0
while i <7:
print(i)
i = i + 1
if i == 4:
break
else:
print('sorry no i')