There is always syntax error occurs


print ‘Welcome to the Pig Latin Translator!’

Start coding here!

original = raw_input("Enter a word:")
def verifier(original):
  if len(original) > 0:
    return print(original)
    return print("empty")

File “python”, line 7
return print(original)
SyntaxError: invalid syntax

May I ask why my codes are wrong?


you can’t have return and print on the same line. Python can do a lot, but that is even too much for python.


Yes Yes!Thank you for your quick reply. May I ask that why I cannot put len(original) as an variable?
like this:def verifier(len(original)) ?


Hi,I have another question here, I figured out why I put “return” there :
The original variable (" tony") had more than 0 characters but did not get printed.

if I delete ’ return ’ and run ,it shows this, whatever I type , the interpreter seems stuck and stops working.


def keyword creates a function, you can’t you can’t convert the parameter (original) to length when defining the parameter

functions only execute when called. Why did you even include a function? Doing more then the exercise asks of you, can cause problems

it shows what?


I mean It shows the error message, ah its my bad,I want to grab every chance I got to practice what I learned in school,probably it is not the right time.Most importantly,Thanks,I never get such help online.


The problem is that adding additional code could sometimes produces errors (depending on how much and what kind of code you add)

And, in programming, why you do something is very important. You can indeed attempt to improve pyglatin program, but then i would ask for feedback on the forum. This feedback will get better if you can “defend” the choices you made, and why they make the program better


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