Python factorial using function, this program doesn't work what is the problem?? Please answer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Python factorial using function, this program doesn't work what is the problem?? Please answer

def fact(n): f=1 for I in range(n): f=f*(I +1) return f num=int(input("enter a num") r=fact(num) print(r) It shows error in 7 line of code https://code.sololearn.com/cdmc03uEDFjw/?ref=app r=fact (num) Syntax Error:invalid syntax( r=fact (num)) in this line

19th Jul 2022, 1:42 PM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
11 Answers
+ 2
AAYUSH AGARWAL Nice! The problem is unbalanced parenthesis in the previous line (the one with input). The input call parenthesis are closed, but the int one are not.
19th Jul 2022, 4:50 PM
Emerson Prado
Emerson Prado - avatar
+ 1
Emerson Prado now check I give full information about that particular code which need to solve or find error in that for you
19th Jul 2022, 4:29 PM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
+ 1
Emerson Prado thanks alot
19th Jul 2022, 4:51 PM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
+ 1
Emerson Prado nice meet with you
19th Jul 2022, 4:52 PM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
0
AAYUSH AGARWAL Pls note this section is intended for questions about programming only. For you to showcase code, pls use your feed.
19th Jul 2022, 1:44 PM
Emerson Prado
Emerson Prado - avatar
0
Emerson prado i ask answer ok
19th Jul 2022, 1:46 PM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
0
AAYUSH AGARWAL Ah, OK. Pls elaborate on "doesn't work". Explain - still in the question description - what is unsatisfying in the results. This is a general advice: the better you explain your problem, the better help you get.
19th Jul 2022, 1:59 PM
Emerson Prado
Emerson Prado - avatar
0
AAYUSH AGARWAL After that, while you wait for answers, pls review range function. Specially, how it interprets the parameter(s).
19th Jul 2022, 2:01 PM
Emerson Prado
Emerson Prado - avatar
0
Emerson Prado I explain it now so please give answer
19th Jul 2022, 2:11 PM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar
0
AAYUSH AGARWAL Pls paste the error message. The error strings have a meaning, and they are key to find the problem. Always give the full information. This helps you to get better help.
19th Jul 2022, 4:22 PM
Emerson Prado
Emerson Prado - avatar
0
Emerson Prado ok
19th Jul 2022, 4:23 PM
AAYUSH AGARWAL
AAYUSH AGARWAL - avatar