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
1list1 = [1,'hello',2] #we've created a list
2for element in list1:
3 print(element) #we will print every element in list1