+ 3
Need some help
14 Antworten
+ 9
it does not print anything because the flow of execution never reaches print statement. the work of function gets over when return statement is encountered
+ 8
@Ham Za I'm not good at Python so I don't know what's wrong.
+ 7
What's the problem here?
+ 6
The problem is the return statement in the line function
+ 4
Remove the `return` at the end of the line function, and instead add a `return list` at the very end of that function. Then use `print(line(y))` at the end. Also, the `list = []` should be inside of the line function
+ 4
#@Hamza, I think you want so
#line from pascal's triangle
y = int(input("input: "))
print()
def factorial(x):
factorial = 1
for i in range(1,int(x)+1):
factorial = factorial * i
return factorial
def combination(a, b):
comb = (factorial(a)/(factorial(b)*factorial(a-b)))
return int(comb)
def line(x):
list = []
for n in range(x+1):
comb = combination(x,n)
list.append(int(comb))
return list
print(line(y))
+ 3
i get nothing in the output
+ 3
??
+ 3
no broblem. thanks anyway
+ 3
And you dont need to implement the binomial coefficient just to generate the triangle
+ 3
@Supersebi3 😅😅😅 I didnt understand a word of what you just said.
which changes should I do?
+ 3
the code worked, but not as planned.
It always outputs '[1, 0]'
+ 3
👍👍👍 thank you