Question
Use Pascal Triangle Template on python: Print Pascal's triangle by adding code to the given template file. Print the triangle up to row 6. Please
Use Pascal Triangle Template on python:
Print Pascal's triangle by adding code to the given template file. Print the triangle up to row 6. Please make sure that the program can run. Thank you.
This is what it should look like.
Also, this is what I have and I'm new to programming, but I keep getting an error on line 8, so if you could help me correct it and explain what had happened, or find a more reasonable solution Id appreciate it.
def pascal_triangle(n): line = [1] a = [] for i in range(n): a.append([]) a[i].append(1) for j in range(1,i): a[i].append(a[i-1][j-1]+a[i-1][j]) if(n>1): a[i].append(1) line = a[n-1] print (line) return line pascal_triangle (6)
def pascal triangle (n): line [1] # Put your code here print (line) return line pascal triangle (6)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started