I seem to be having a problem with creating a pascal's triangle in python, and I'm really realyl frustrated not finding the problem. Please help. Thanks.
Heres the code:
inpt = input("Enter levels: ") #number of levels in a triangle
list1 = []
list2 = [1]
for a in range(inpt):
list1.append(1)
for x in range(a+1):
if (x == 0 or x == a):
list1[x]
elif (x > 0 or x < a):
list1[x] = list2[x] + list2[x-1]
print list1
list2 = list1
and it prints something like this:
[1]
[1, 1]
[1, 2, 1]
[1, 3, 4, 1]
[1, 4, 8, 9, 1]