Often times we want to create a list containing a continuous value like, in a range of 100-200. Let’s discuss how to create a list using the
Will this work ?
As we can see in the output, the result is not exactly what we were expecting because Python does not unpack the result of the range() function.
Code #1: We can use argument-unpacking operator i.e. *.
As we can see in the output, the argument-unpacking operator has successfully unpacked the result of the range function.
Code #2 : We can use the
extend() function to unpack the result of range function.
- Python | Numbers in a list within a given range
- Python | Alternate range slicing in list
- Python | Decimal step range in list
- Python | Create list of numbers with given range
- Python | Assign range of elements to List
- Python | Size Range Combinations in list
- Python | Construct N Range Equilength String list
- Python | Print list elements in circular range
- Python | Front and rear range deletion in a list
- Python List Comprehension | Three way partitioning of an array around a given range
- Python | Generate random numbers within a given range and store in a list
- Python | Find missing numbers in a sorted list range
- Python | Convert list of string to list of list
- Python | Convert list of tuples to list of list
- Python | Convert mixed data types tuple list to string 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.