Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

def getInput(): tHeight = int(input(\'Please enter the height of the triangle: \

ID: 3641497 • Letter: D

Question

def getInput():
tHeight = int(input('Please enter the height of the triangle: '))
return tHeight

def Pascal(num):

if (num == 1):
return [1]

else:
line = [1]
prev_line = Pascal(num-1)

for j in range (len(prev_line)-1):
line.append(prev_line[j] + prev_line[j+1])
line += [1]
return line

#The main body of program
printInfo()
Height=getInput()
Pascal(Height)
print (Pascal (Height))

The output is:
Please enter the height of the triangle: 5
[1, 4, 6, 4, 1]

The output I'm looking for is:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Explanation / Answer

The program you pasted is incomplete, so I couldn't run it.
There's no printInfo(), and even when I take that out and input 5, the program is outputting [1] instead of [1,4,6,4,1] that you have.
Part of it might also be because of indentation ambiguity, idk.
Assuming that your output is what you are getting, then...

From what I see, it looks like you are only trying to print it once Pascal(Height)) has already return its list. If you want the desired output, you should either put a print statement inside the function so that it prints it each time you make a new list, or you could do something like:
...
for i in range(1,Height+1):
print(Pascal(i))
...