for num, data in enumerate(test_data[:len(test_data)]):
I have a code snippet like this. Let's say I have 30 data, in the test data. Is this for loop goes from 0 to 30 or from 0 to 29?
CodePudding user response:
Looks like 0 to 29:
>>> test_data = [n for n in range(0,30)]
>>> for num, data in enumerate(test_data[:len(test_data)]):
... print(num)
...
0
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
CodePudding user response:
You can test it by printing the count.
for i in range(0,4):
print(i)
Output:
0 1 2 3