Reputation: 90
Code:
def is_num(num1):
try:
int(num1)
return True
except ValueError:
return False
Consol Output:
except ValueError:
^
SyntaxError: invalid syntax
I started python about 5 days ago so I don't relly understand the error or how to fix it. Please help.
Upvotes: 1
Views: 1823
Reputation: 181
You forgot to indent the function body This is working :
def Foo():
try:
raise Exception("error")
except Exception :
print "test"
Upvotes: 2