Okay can someone tell me if my current code is even possible. I have to create pascals triangle with an input WITHOUT using any loops. I am bound to recursion.
Ive spent 3 days on this, and this is the best output that I can come up with. its driving me INSANE
def pascal(curlvl,newlvl,tri):
if curlvl == newlvl:
return ""
else:
tri.append(tri[curlvl])
print(tri)
return pascal(curlvl+1,newlvl,tri)
def triLvl():
msg = "Please enter the number of levels to generate:"
triheight = int(input(msg))
if triheight < 1:
print("n Sorry, the number MUST be positiven Please try again.")
return triLvl()
else:
return triheight
def main():
triangle = [1]
curlvl = 0
print("Welcome to the Pascal's triangle generator.")
usrTri = triLvl()
print(triangle)
pascal(curlvl,usrTri,triangle)
main()
