Python-programming-exercises icon indicating copy to clipboard operation
Python-programming-exercises copied to clipboard

Line 1975 error

Open Liminal1 opened this issue 6 years ago • 7 comments

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,

Liminal1 avatar Oct 19 '18 22:10 Liminal1

Hi @Liminal1, I don't think there is any problem if you just put the parentheses on the 'print()' statement.

ashwanidv100 avatar Oct 20 '18 13:10 ashwanidv100

Yes that worked. Thank you!

Liminal1 avatar Nov 08 '18 23:11 Liminal1

i'm using latest 3.65 python in pycharm and it shows syntax error.

itsnitinthakur avatar Feb 20 '19 18:02 itsnitinthakur

def fact(x): if x == 0: return 1 return x * fact(x - 1)

x=int(raw_input()) print fact(x)

itsnitinthakur avatar Feb 20 '19 18:02 itsnitinthakur

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.

RagdollSL avatar Feb 20 '19 23:02 RagdollSL

It looks like this issue was resolved in 2019. Is there any reason why it is still open?

mikeysan avatar Dec 29 '20 14:12 mikeysan

Looks like repo owner or contributors does not moderate the repo actively. Please use https://github.com/ashwanidv100/Python-programming-exercises for best practices.

ashwanidv100 avatar Dec 30 '20 03:12 ashwanidv100