programming-examples/python/Function/Python function that that prints out the first n rows of Pascal's triangle.py

8 lines
200 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def pascal_triangle(n):
trow = [1]
y = [0]
for x in range(max(n,0)):
print(trow)
trow=[l+r for l,r in zip(trow+y, y+trow)]
return n>=1
pascal_triangle(6)