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.