Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Python :: python check if class has any methods 
Python :: python ravel function output 
Python :: using the return statement, defining a function, with input from the user. 
Python :: Crop Image as Circle with transparent background 
Python :: reminder application with notification in python 
Python :: python tuple first column 
Python :: python variable type casting 
Python :: python slicing string 
Python :: string to 2d array python 
Python :: save media file from url python 
Python :: Django is MVT Not MVC 
Python :: safe password in python 
Python :: Display summary of all the numerical variables in the DataFrame 
Python :: method 01 of making GUI with tkinter in python 
Python :: login() takes 1 positional argument but 2 were given 
Python :: Adding new nested object using Shallow copy 
Python :: python generate c array 
Python :: python workbook.add_format in percentage 
Python :: check true false in python 
Python :: pandas assign multiple columns 
Python :: packing a tuple 
Python :: how to install pygame for python 3.8.5 
Python :: emi calculator python code 
Python :: python two list into dictinaray 
Python :: what is flash in flask 
Python :: dataframe no names from file 
Python :: how to save all countries from a list in a database python 
Python :: get resource path python 
Python :: django template child data in nested loop 
Python :: Python program to read a random line from a file. 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =