Hello World ! My question is how to make a program in Python3 to print the following pattern : | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hello World ! My question is how to make a program in Python3 to print the following pattern :

1 1 2 1 2 3 1 2 3 4 1 2 3 4 5

17th Jan 2017, 5:26 PM
Advik Singhania
Advik Singhania - avatar
3 Answers
+ 5
as a function which takes start and end paramaters and prints the triangle def tri(start,end): for x in range(start,end+1): for y in range(start,x+1): print(y,end=' ') print() tri(1,7) tri(2,8)
17th Jan 2017, 7:39 PM
Burey
Burey - avatar
+ 4
for x in range(1,6): for y in range(x): print(y+1,end=' ') print() # for line drop tho i am sure there is a more stylish code for this task...
17th Jan 2017, 7:25 PM
Burey
Burey - avatar
+ 2
also this is possible print_range=lambda x:print(*x) for x in range(1,6): print_range([y for y in range(1,x+1)])
17th Jan 2017, 7:32 PM
Burey
Burey - avatar