So I am creating a program to generate pascal’s triangle, which I know has been done to death, however the way I am told to go about it is different then how I would have thought. I am just needing some help translating the beginning so that I can get it rolling. It basically states assign a list to be empty to represent the triangle and
for each row of the triangle from 0 to the height+1 assign a list to be empty to represent one new row of the triangle.If the new row is row zero make the new row to be a [1].
So what I have so far is
h=input("enter height")
mytri=[]
for i in range(0,h+1):
row=[ ]
if i==0:
newrow=[1]
elif newrow==1:
#here is where I get lost
Where I am having trouble is finding out how to tell if the new row is row zero or row 1. Have yet to see anything like that in my short experience with python. Any help is greatly appreciated.
In your third line, you are running a
forloop, so that will be aforthere instead of anif.Coming to your question, you need to know the row number and check whether it is something, right? Look carefully, what variable in your code corresponds to the row number?