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 | Decimal step range in list
- Python | Alternate range slicing in list
- Python - Specific Range Addition in List
- Python | Merge Range Characters in List
- Python - Test if List contains elements in Range
- Python | Size Range Combinations in list
- Python | Create list of numbers with given range
- Python | Assign range of elements to List
- Python | Construct N Range Equilength String list
- Python List Comprehension | Three way partitioning of an array around a given range
- Python | Front and rear range deletion in a list
- Python | Print list elements in circular range
- Python | Find missing numbers in a sorted list range
- Python | Generate random numbers within a given range and store 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.