Write a python program to print the following pattern:
0
22
444
6666
88888
Answers
Answered by
4
Answer:
print("Approach 1:-")
for i in range(0,5):
for j in range(i+1):
print(i*2,end="")
print()
print("\n\nApproach 2:-")
#Using 1 loop
for i in range(5):
print(str(i*2)*(i+1))
print("\n\nAproach 3:-")
#One-liner Approach
print("\n".join((str(i*2))*(i+1) for i in range(5)))
Attachments:
Similar questions