0

I have been running though a lot of examples in python and got to this function code. I can not seem to understand this code, specifically what line 6 is saying (starts with row = )

def pascal(n):
    row = [1]
    y = [0]
    for x in range(n):
        print(row)
        row = [l+r for l, r in zip(row+y, y+row)]
    return n
pascal(4)

thanks in advance!!!

LF00
  • 22,077
  • 20
  • 117
  • 225
  • That's a list comprehension. Basically works the same as the `map` function, but also allows for filtering. – Carcigenicate May 29 '17 at 03:00
  • https://stackoverflow.com/questions/34835951/what-does-list-comprehension-mean-how-does-it-work-and-how-can-i-use-it is probably a better link, actually. – metatoaster May 29 '17 at 03:05

0 Answers0