+ 2
I want this in one line : for - if - list
4 Answers
+ 7
print([v for i, v in enumerate(list) if not i % 2])
+ 6
But don't use 'list' as a variable name, you end up redefining the type.
for instance;
list() function will no longer work
+ 2
You can also take a slice of the list: list1[::2]
https://www.geeksforgeeks.org/JUMP_LINK__&&__python__&&__JUMP_LINK-list-comprehension-and-slicing/
+ 1
Sorry I mean list1