-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfor loop.py
72 lines (53 loc) · 973 Bytes
/
for 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
N=["A","B","C"]
for x in N:
print(x)
#for loop for string
for x in "kajal":
print(x)
#for integer 1st method
for x in [1,2,3,4]:
print(x)
#2nd method
y=[1,2,3,4]
for n in y:
print(n)
for x in "kajal":
print(x,end="")
#break statement use in for
y=[1,2,3,4]
for n in y:
print(n)
if n==3:
break
y=[1,2,3,4]
for n in y:
if n==3:
break
print(n)
y=[1,2,3,4]
for n in y:
if n==3:
continue
print(n)
x=["kajal","charu","best friend"]
for y in x:
if y=="charu":
continue
print(y)
for x in range(10):
print(x)
for x in range(10):
print(x,end=" ")
for x in range(2,9):
print(x)
for x in range(1,50,2):
print(x)
for x in range(10):
print(x)
else:
print("hello kajal")
name=["kajal","charu"]
hobby=["cricket","dance"]
for x in name:
for y in hobby:
print(x,y)