1#x starts at 1 and goes up to 80 @ intervals of 2
2for x in range(1, 80, 2):
3 print(x)
1Python Loops
2
3for x in range(1, 80, 2):
4 print(x)
5
6words=['zero','one','two']
7for operator, word in enumerate(words):
8 print(word, operator)
9
10for x in range(1, 80, 2):
11 print(x)
12
13
14
15
16
1for i in range(1,10,2): #(initial,final but not included,gap)
2 print(i);
3 #output: 1,3,5,7,9
4
5for i in range (1,4): # (initial, final but not included)
6 print(i);
7 #output: 1,2,3 note: 4 not included
8
9for i in range (5):
10 print (i);
11 #output: 0,1,2,3,4 note: 5 not included
12
13python = ["ml","ai","dl"];
14for i in python:
15 print(i);
16 #output: ml,ai,dl
17
18for i in range(1,5): #empty loop...if pass not used then it will return error
19 pass;
20
1text = "Hello World"
2for i in text:
3 print(i)
4#Output
5#H, e, l, l, o, , W, o, r, l, d
6for i in range(10):
7 print(i)
8#1, 2, 3, 4, 5, 6, 7, 8, 9, 10