Hi there – anyone has a clue why this is working?
I would expect the opposite to work, i.e. if num % 2 != 0 then the list should slice, while if num % 2 == 0 it should continue…
Appreciate any help in understanding this!
X
Hi there – anyone has a clue why this is working?
I would expect the opposite to work, i.e. if num % 2 != 0 then the list should slice, while if num % 2 == 0 it should continue…
Appreciate any help in understanding this!
X
The code for num in lst
iterates through the elements in lst and not their index. Try printing this to see what might be occurring in certain (but not all) statements that rely on num
-
for num in lst:
print(num)