
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Increasing alternate element pattern in list in Python
In this tutorial, we are going to write a program that includes increasing order of an element to the given list after each element. Let's see an example to understand it clearly.
Input
alphabets = ['a', 'b', 'c']
Output
['a', '#', 'b', '##', 'c', '###']
Follow the below steps to solve the problem.
- Initialize a list.
- 3Create an empty list.
- Iterate over the initial list.
- Add the current element and the respective number of hashes to the empty list.
- Print the resultant list.
Example
# initializing the list alphabets = ['a', 'b', 'c'] # empty list result = [] # iterating over the alphabets for i in range(len(alphabets)): # appending the current element result.append(alphabets[i]) # appending the (i + 1) number of hashes result.append((i + 1) * '#') # printing the result print(result)
Output
If you run the above code, then you will get the following result.
['a', '#', 'b', '##', 'c', '###']
Conclusion
If you have doubts regarding the tutorial, mention them in the comment section.
- Related Articles
- Python - Increasing alternate element pattern in list
- Alternate element summation in list (Python)
- Alternate range slicing in list (Python)
- Python – Check alternate peak elements in List
- Python – Cross Pattern Pairs in List
- A strictly increasing linked list in Python
- List consisting of all the alternate elements in Python
- Check if list is strictly increasing in Python
- Sort a List of Tuples in Increasing Order by the Last Element in Each Tuple using Python program
- Python program to Sort a List of Tuples in Increasing Order by the Last Element in Each Tuple
- Python - List Initialization with alternate 0s and 1s
- Element repetition in list in Python
- Find groups of strictly increasing numbers in a list in Python
- Alternate sorting of Linked list in C++
- Binary element list grouping in Python

Advertisements