How do I insert an item into a list at a specific index? Without using:
index = 3
list = [:3] + [item] + [3:]
Help!
How do I insert an item into a list at a specific index? Without using:
index = 3
list = [:3] + [item] + [3:]
Help!
You can use the insert method:
lst = ['a','b','c']
lst.insert(2,'d')
print(lst)
Output:
['a','b','d','c']