Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

append multiple once python

you can use list.append() to append a single value, and list.extend() to append multiple values.
Comment

append multiple elements python

>>> lst = [1, 2]
>>> lst.append(3)
>>> lst.append(4)
>>> lst
[1, 2, 3, 4]

>>> lst.extend([5, 6, 7])
>>> lst.extend((8, 9, 10))
>>> lst
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

>>> lst.extend(range(11, 14))
>>> lst
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
Comment

PREVIOUS NEXT
Code Example
Python :: python update function 
Python :: convert dictionary to string 
Python :: python label 
Python :: range parameters python 
Python :: pygame python 
Python :: list input python 
Python :: k fold cross validation 
Python :: bounding box in python 
Python :: add an index column in range dataframe 
Python :: leetcode solutions python 
Python :: id() python 
Python :: py scrapy 
Python :: list len python 
Python :: * pattern program in python 
Python :: How to perform heap sort, in Python? 
Python :: df read csv 
Python :: run python from c# 
Python :: what is repr function in python 
Python :: Count upper case characters in a string 
Python :: numpy arange number of elements 
Python :: miles to km in python 
Python :: Open the .txt file 
Python :: how to convert one dimensional array into two dimensional array 
Python :: django reverse lazy 
Python :: dataframe cut 
Python :: decoding 
Python :: python sort dictionary case insensitive 
Python :: how to store data in python 
Python :: python how to make a user input function 
Python :: python subprocess no such file or directory 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =