+ 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
3 Respostas
+ 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)
+ 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...
+ 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)])