I am working on the following code:
def numberToName(number):
if (number==3):
return "Three"
elif (number==2):
return "Two"
elif (number==1):
return "One"
else:
return "Invalid"
print numberToName(2)
print numberToName(3)
print numberToName(1)
print numberToName(1)
This code runs 100% fine in the following online Python environment - http://www.codeskulptor.org/#user11_Hh0KVUpNVP_0.py
But when I use IDLE
it shows a syntax error Invalid Syntax
in line print numberToName(2)
My Python version is 3.3.1
I have noticed some issues as well. For an example, in the given URL, I can run print "hello"
and get the output, but the same generated error in IDLE unless I type print ("Hello")
.
What is the issue here? I am new to Python.
(Please note the main question is about the given code snippet).