Sometimes, while working with Python list, we can have a problem in which we need to extend a list in a very customized way. We may have to repeat contents of list and while doing that, each time new list must add a number to original list. This incremental expansion has applications in many domains. Let’s discuss a way in which this task can be performed.
Method : Using list comprehension
This task can be performed in a brute manner, but having a shorter implementation using list comprehension always is better. In this, we perform task in 2 steps, first we make a helper list to form a addition factor list and then cumulate the result using original list.
The original list is : [7, 8, 9] List after extension and addition : [7, 8, 9, 10, 11, 12, 16, 17, 18, 34, 35, 36]
- Python | Incremental slice partition in list
- Python - Incremental and Cyclic Repetition of List Elements
- Python | Repeat and Multiply list extension
- Python - Incremental Sublist Sum
- Python - Incremental value initialization in Dictionary
- Python | Incremental Records Product
- Python | N element incremental tuples
- Python - Incremental Range Initialization in Matrix
- Python - Incremental K sized Row Matrix Initialization
- Python | Reverse Incremental String Slicing
- C Extension Module using Python
- C API from Extension Module in Python | Set 2
- C API from Extension Module in Python | Set 1
- Python | Passing Filenames to Extension in C
- Python | Opaque Pointers in C extension modules
- Python | Extension function operating on Arrays
- Python | Sort and store files with same extension
- Pafy - Getting Extension of Stream
- Python | Convert list of string to list of list
- Python | Convert list of tuples to list of 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.