I need to write the Hosoya's Triangle program in Python that print out the following result if we need 5 levels. The function should be recursive and follow the mentioned structure:

def computeTriangle(levels):
if levels == 0:
return []
elif levels == 1:
return [[1]]
else:
triangle = computeTriangle(levels-1)
row = [1]
for i inrange(1, levels-1):
row.append(triangle[-1][i-1] + triangle[-1][i])
row.append(1)
triangle.append(row)
return triangle
# Function to print the Hosoya Triangledef printTriangle(triangle, levels):
for i inrange(levels):
row = [str(triangle[i][j]) for j inrange(i+1)]
print(" ".join(row))
# Main functiondef main():
# Compute and print the Hosoya Triangle
levels = int(input("Enter the number of levels of the Hosoya Triangle to compute: "))
triangle = computeTriangle(levels)
printTriangle(triangle, levels)
if __name__ == '__main__':
main()

Have a look here: Hosoya's Triangle - GeeksforGeeks[^] - it explains what you have to do pretty well, and provides code samples - I'd suggest you largely ignore them as you won't learn much unless you do it yourself.