Answers for "how to append an element in a list in python"

1

how to append list in python

list_1 = ['w','h']
list_1.append('y')        # you need no veribal to store list_1.append('y')
print(list_1)             # ['w','h','y']

list_2 = ['a','r','e']
list_1.append(list_2)     # This also donot need a veribal to store it
print(list_1)             # ['w','h','y',['a','r','e']]

list_1.extend(list_2)
print(list_1)             # ['w','h','y',['a','r','e'],'a','r','e']
# please like
Posted by: Guest on July-11-2021
0

add an element to list python

a=[8,5,6,1,7]
a.append(9)
Posted by: Guest on May-31-2020

Code answers related to "how to append an element in a list in python"

Python Answers by Framework

Browse Popular Code Answers by Language