```
class Solution(object):
def generate(self, numRows):
result = []
for i in range(numRows):
row = [1]
for j in range(i):
try:
row.append(result[-1][j] + result[-1][j+1])
except IndexError:
row.append(1)
result.append(row)
return result
```