def printTriangle(lst):
it = iter(lst) # iter() function returns an iterator for the given object
i = 0
while True:
lst_val = next(it, None) # gets the next value
if lst_val:
print(lst_val, *(next(it) for _ in range(i)))
i += 1
else:
break
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
printTriangle(lst)
'''
run:
1
2 3
4 5 6
7 8 9 10
'''