Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Swap first and last list elements

temp = normal[0]  			# save first value to temp
normal[0] = normal[-1]		# change last value to first value
normal[-1] = temp			# change last value to temp value 

# You can do it in one line   x[0], x[-1] = x[-1], x[0]
normal[-1], normal[0] = normal[0], normal[-1]
Comment

PREVIOUS NEXT
Code Example
Python :: how to count repeated words in python 
Python :: python input list of ints 
Python :: python json write utf 8 
Python :: python convert string to list 
Python :: too many python versions pip package location 
Python :: python code to get wifi 
Python :: sns boxplot 
Python :: purpose of meta class in django 
Python :: how to use %s python 
Python :: python multiply 2 variables 
Python :: max deviation in pandas 
Python :: remove from list if not maches in list 
Python :: two groupby pandas 
Python :: indexing python first and last 
Python :: know the type of variable in python 
Python :: python set match two list 
Python :: convert list of lists to pandas dataframe 
Python :: how to python 
Python :: series astype 
Python :: compare multiple columns in pandas 
Python :: how to use assert in python 
Python :: self in python 
Python :: while loops python 
Python :: .lift tkinter 
Python :: python convert bytes to string 
Python :: check if all elements in list are equal 
Python :: turtle graphics documentation 
Python :: how to install ffmpeg_streaming in python 
Python :: using Decorators 
Python :: missing data in python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =