Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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]
 
PREVIOUS NEXT
Tagged: #Swap #list #elements
ADD COMMENT
Topic
Name
4+2 =