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