-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path"For...in" loop
52 lines (50 loc) · 1.21 KB
/
"For...in" loop
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
list1 = [7, 10, 210, 30, 440, 50, 960, 780, 80, 90, 10000, 501321] #This is the list
for item in range(len(list1)): #range gives me how many values in list
print(item) #item is evey value in the list
# For its a loop that deals with every value
result:
0
1
2
3
4
5
6
7
8
9
10
11
***************************************************************************************
list1 = [7, 10, 210, 30, 440, 50, 960, 780, 80, 90, 10000, 501321] #This is the list
for item in range(len(list1)): #range gives me how many values in list
print(list1[item]) #item is evey value in the list
OR:
list1 = [7, 10, 210, 30, 440, 50, 960, 780, 80, 90, 10000, 501321] #This is the list
for item in list1: #range gives me how many values in list
print(item) #item is evey value in the list
# For...in it's a loop that deals with every value.
result:
7
10
210
30
440
50
960
780
80
90
10000
501321
****************************************************************************************
list1 = [7, 10, 210, 30, 440, 50, 960, 780, 80, 90, 10000, 501321] #This is the list
for item in range(0, len(list1), 2): #using range structure to navigate list
print(list1[item]) #item is every value in the list
result :
7
210
440
960
80
10000