“SyntaxError: 'return' outside function” What does that mean?


#1



File "python", line 6
SyntaxError: 'return' outside function


I thought it would work out OK but...


print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word:")
if len(original) > 0:
    return original()
else:
    return "empty"


#2

return can only be used inside functions (and methods), you have neither


#3

?? What does that mean?
Can you help me correct my code?


#4

well, that return is not write, the instructions give a pretty big hint about what you should use:

If the string actually has some characters in it, print the user's word.
Otherwise (i.e. an else: statement), please print "empty".


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.