Removing items from list with single line
# Removing items with even-numbered indices
[ list.remove(item) if (list.index(item) % 2 == 0) else item for item in list ]
Written by Kamil Michalak
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Related Tags
#python
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#