Write a python program to remove the item present at index 4 and add it to the 2nd position and at the end of the list.
belongs to collection: Python Data Structure Exercises
All Answers
total answers (1)
belongs to collection: Python Data Structure Exercises
total answers (1)
Hint:
Use the list methods,
pop()
,insert()
andappend()
Solution:
pop(index)
: Removes and returns the item at the given index from the list.insert(index, item)
: Add the item at the specified position(index) in the listappend(item)
: Add item at the end of the list.