This solution turns out only great for Python 2 - I executed your code on Hackerrank and it breezed through all the test cases.
Along these lines, the compilation error appears if the code is gathered with Python 3.
no = int(raw_input())
NameError: name 'raw_input' is not defined
That is genuine on the grounds that raw_input should be replaced with a input() in Python 3.
In the event that the code with the amendment is executed subsequently, there's another issue:
print fac(no)
^
SyntaxError: invalid syntax
Once more, simply add brackets around fac(no), and afterward, the code accumulates and breezes through all the tests:
In this way, the full code is underneath:
def fac(n):
return 1 if (n < 1) else n * fac(n-1)
no = int(input())
print (fac(no))
Are you interested to learn the concepts of Python? Join the python training course fast!