How do we add new elements in the list at a particular position in the list?
1 answers ( 0 marked as helpful)
Hi Sayed!
Great to have you in the course and thanks for reaching out!
You can use the
Martin
.insert()
method to do that. The syntax structure to follow is list_name.insert(index, element)
. I.e., in the list called list_name
, this will insert element
in the given index
, shifting the elements to the right.
Hope this helps.
Best,Martin