Python-programming-exercises
Python-programming-exercises copied to clipboard
Line 1975 error
Hello,
The problem on line 1975 throws a syntax error. I am using python 3.6 and was wondering if the error is due to that or something else.
Thank You,
Hi @Liminal1, I don't think there is any problem if you just put the parentheses on the 'print()' statement.
Yes that worked. Thank you!
i'm using latest 3.65 python in pycharm and it shows syntax error.
def fact(x): if x == 0: return 1 return x * fact(x - 1)
x=int(raw_input()) print fact(x)
Cuz it is Python 2 code.
In Python 2, raw_input() get your input as a string, it is same as input() in Python 3. And in Python 2, print is a statement, so you don't need to write parentheses behind it. However, in Python 3, print() is a function, you must put parentheses behind it.
So you should change raw_input() into input(), and change 'print fact(x)' into 'print(fact(x))', and see if it works.
It looks like this issue was resolved in 2019. Is there any reason why it is still open?
Looks like repo owner or contributors does not moderate the repo actively. Please use https://github.com/ashwanidv100/Python-programming-exercises for best practices.