Sometimes, while working with Python list we can have a problem in which we need to construct the list in which the range is auto computed using the start, end and length parameters. The solution of this problem can have many applications. Let’s discuss a way in which this task can be performed.
Method : Using list comprehension
This task can be performed using list comprehension, shorthand for the loop version of logic. In this, we just compute the range using division manipulation and extend it to increasing list forming equidistant list.
The Equidistant list is : [5.0, 5.625, 6.25, 6.875, 7.5, 8.125, 8.75, 9.375]
- Python | Replace elements in second list with index of same element in first list
- Python | Indices list of matching element from other list
- Python | Slicing list from Kth element to last element
- Python | Move one list element to another list
- Python | How to get the last element of list
- Python | Every Kth element in list
- Python | Three element sum in list
- Python | Move element to end of the list
- Python | Remove given element from the list
- Python | Operate on every Kth element of list
- Python | Removing first element of list
- Python | Operation to each element in list
- Python | Element repetition in list
- Python | Add the element in the list with help of indexing
- Python | Last occurrence of some element in a 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 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.