Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python reverse list every 2 element

elems = list(range(10))
print(elems)
print(elems[::2])
print(elems[-2::-2])
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# [0, 2, 4, 6, 8]
# [8, 6, 4, 2, 0]
Comment

PREVIOUS NEXT
Code Example
Python :: flask make_response render_template 
Python :: Python Decorating Functions with Parameters 
Python :: Python Raw string using r prefix 
Python :: get external ip address python 
Python :: pandas replace not working 
Python :: pie plot chance size python 
Python :: pandas mappin ID to value in different row 
Python :: How to provide type hinting in UserDict? 
Python :: lol infinite print in python 
Python :: prettytable in python 
Python :: how to change the title of the top bar in python 
Python :: python scatter matrix with regression line 
Python :: python string count complexity 
Python :: telegram bot python 
Python :: rest api save file python 
Python :: Passive to active Python 
Python :: Normalize basic list data 
Python :: how to produce txt file from list python 
Python :: patoolib extract password-protected archives 
Python :: add all columns in django 
Python :: update value in xml python 
Python :: loc condition on first 3 columns of dataframe 
Python :: basic decorator example 
Python :: how to create a sub project in django 
Python :: how many python programmers in the world 
Python :: shutil cut poython 
Python :: houghlinesp python stackoverflow 
Python :: command in python to make negative number positive 
Python :: 2d grid python pygame 
Python :: table and amorization charts using tkinter 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =