11th Nov 2017, 2:18 PM
Hamza Boudouche
14 Respostas
+ 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
11th Nov 2017, 3:02 PM
Gaurav Gupta
Gaurav Gupta - avatar
+ 8
@Ham Za I'm not good at Python so I don't know what's wrong.
11th Nov 2017, 2:58 PM
qwerty
qwerty - avatar
+ 7
What's the problem here?
11th Nov 2017, 2:38 PM
qwerty
qwerty - avatar
+ 6
The problem is the return statement in the line function
11th Nov 2017, 3:01 PM
Supersebi3
Supersebi3 - avatar
+ 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
11th Nov 2017, 3:13 PM
Supersebi3
Supersebi3 - avatar
+ 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))
11th Nov 2017, 3:32 PM
Ferhat Sevim
Ferhat Sevim - avatar
+ 3
i get nothing in the output
11th Nov 2017, 2:39 PM
Hamza Boudouche
+ 3
??
11th Nov 2017, 2:55 PM
Hamza Boudouche
+ 3
no broblem. thanks anyway
11th Nov 2017, 2:59 PM
Hamza Boudouche
+ 3
And you dont need to implement the binomial coefficient just to generate the triangle
11th Nov 2017, 3:08 PM
Supersebi3
Supersebi3 - avatar
+ 3
@Supersebi3 😅😅😅 I didnt understand a word of what you just said. which changes should I do?
11th Nov 2017, 3:12 PM
Hamza Boudouche
+ 3
the code worked, but not as planned. It always outputs '[1, 0]'
11th Nov 2017, 3:32 PM
Hamza Boudouche
+ 3
👍👍👍 thank you
11th Nov 2017, 3:42 PM
Hamza Boudouche