Method # 1: Using the
+ operator and slicing the list
These operators can be used to accomplish this particular task. The add operation can be done using the + operator, and the back removal can be done using a regular slice of the list.
The original list: [4, 5, 7, 3, 10] The list after append and removal: [13, 4, 5, 7, 3]
Method # 2: Using
A double ended queue can be used to do this particular task, which supports python using the collection library to get the job done the appendleft and pop methods of the queue function can be used.
The original list: [4, 5, 7, 3, 10] The list aft er append and removal: [13, 4, 5, 7, 3]