Answers for "how to append a list of numbers in python"

2

how to append a number to a list in python

l = [1, 2, 4, 5] 
new_item = 6
l.append(6)
print(l)
Posted by: Guest on March-17-2021
1

python append n numbers to list

# Basic syntax:
your_list.extend([element]*number)
# Where:
#	- element is the element you want to add to your_list
#	- number is the number of times you want it repeated

# Note, .extend modifies your_list in place

# Example usage:
your_list = [1, 2, 3]
your_list.extend([0]*5)
print(your_list)
--> [1, 2, 3, 0, 0, 0, 0, 0]
Posted by: Guest on November-11-2020

Code answers related to "how to append a list of numbers in python"

Python Answers by Framework

Browse Popular Code Answers by Language