Answers for "how to use insert list python"

0

insert an element in list python

>>> a = [1, 2, 4]
>>> print a
[1, 2, 4]

>>> print a.insert(2, 3)
None

>>> print a
[1, 2, 3, 4]

>>> b = a.insert(3, 6)
>>> print b
None

>>> print a
[1, 2, 3, 6, 4]
Posted by: Guest on June-20-2021
0

list insert method in python

l1 = [1, 8, 7, 2, 21, 15]
 l1.insert(2, 544) # inserts 544 at index 2
  print(l1)
Posted by: Guest on January-12-2022

Code answers related to "how to use insert list python"

Python Answers by Framework

Browse Popular Code Answers by Language