How to print the following pattern? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to print the following pattern?

11111 2222 333 44 5

14th Sep 2018, 2:53 PM
Sanjay Govind S
Sanjay Govind S - avatar
2 Answers
14th Sep 2018, 4:08 PM
PROTON
PROTON - avatar
+ 2
Probably not how your teacher wants to have it, but it works: n = 5 i = 0 while True: for j in range(n, 0, -1): print(j * str(i+1)) #maybe you need to do this with another for loop if you use a different language i += 1 break (If you need it in a different language than python, feel free to translate the code to the programming language of your choice)
14th Sep 2018, 3:31 PM
Anna
Anna - avatar