write a program to print following pattern 1 22 333 4444 55555
Answers
Answered by
5
Answer:
def create_sequence():
n = int(input('Enter the number till which you want the sequence:'))
for i in range(1,n+1):
print(str(i) * i)
create_sequence()
Explanation:
Above code is implemented in Python language. Python has a functionality that if you multiply a string with a number it will repeat that string that many times. Same has been implemented here. In the for loop we have used function str() to convert value of i to string and has multiplied with i itself hence generating the sequence.
Answered by
1
Answer:
This program prints or generates 1-22-333-4444 pattern up to n lines given by user in Python language.
Similar questions