Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to store only the first and last item of a list in variable python

letters = ["a","b","c","d","e","f"]
# wirte the name of variables for the first and last
# write an astros for the variable between them
first , *other, last = letters
print(first)  # unpacked
print(other)  # packed
print(last)   # unpack

#output:
#a
#['b', 'c', 'd', 'e']
#f
 
PREVIOUS NEXT
Tagged: #store #item #list #variable #python
ADD COMMENT
Topic
Name
5+6 =