Sometimes, while working with Python lists, we can have a problem in which we require to extract every Kth element of list and slice out a new list from that. This type of problems are quite common as a variation of list slicing. Let’s discuss a way in which this can be done.
Method : Using list slicing
This task can be performed using list slicing functionality. The trick here is to use the skip functionality of list to get every Kth element of list. K, as defined can be used as skip element.
The original list : [6, 4, 8, 9, 10, 5, 8, 9, 10, 2, 34, 5] Kth element list is : [6, 9, 8, 2]
- Python | Replace elements in second list with index of same element in first list
- Python | Subtract two list elements if element in first list is greater
- Python | Indices list of matching element from other list
- Python | Slicing list from Kth element to last element
- Python | Insert Nth element to Kth element in other list
- Python | Move one list element to another list
- Python | Three element sum in list
- Python | How to get the last element of list
- Python | Operate on every Kth element of list
- Python - Sum of each List element occurrence in another
- Python | Remove given element from the list
- Python | Equidistant element list
- Python | Insert after every Nth element in a list
- Python | Add the element in the list with help of indexing
- Python | Top N pairs by Kth element from list
- Python - Double each List element
- Python | Last occurrence of some element in a list
- Python | Move element to end of the list
- Python | Element repetition in list
- Python | Every Kth element removal in List
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.