Sometimes, while working with Python list, there can be a problem in which we need to perform the inter list shifts of elements. Having solution to this problem is always very useful. Let’s discuss certain way in which this task can be performed.
Method : Using
pop() + insert() + index()
This particular task can be performed using combination of above functions. In this we just use the property of pop function to return and remove element and insert it to the specific position of other list using index function.
The original list 1 is : [4, 5, 6, 7, 3, 8] The original list 2 is : [7, 6, 3, 8, 10, 12] The list 1 after insert is : [4, 5, 6, 12, 7, 3, 8] The list 2 after remove is : [7, 6, 3, 8, 10]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python | Insert after every Nth element in a list
- Python - Extract Kth element of every Nth tuple in List
- Python | Indices list of matching element from other list
- Python | Slicing list from Kth element to last element
- Python | Insert list in another list
- Python program to insert an element into sorted list
- Python | Remove all values from a list present in other list
- Python | Sort list according to other list order
- Python - Rearrange list by other list order
- Python - Combine list with other list elements
- Python | Operate on every Kth element of list
- Python | Every Kth element in list
- Python | Remove duplicates based on Kth element tuple list
- Python | Top N pairs by Kth element from list
- Python - Concatenate Kth element in Tuple List
- Python | Every Kth element removal in List
- Python - Filter Tuples by Kth element from List
- Python - Maximum of K element in other list
- Python | Accessing nth element from tuples in list
- Python | Sort tuple list by Nth element of tuple
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.