SyntaxError: invalid syntax


#1

I have a question, I’m working on the Pig latin translation and I keep getting an error about the “SyntaxError: invalid syntax” and I have no idea how I can solve this or where I’m doing it wrong.

print 'Welcome to the Pig Latin Translator!'

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

#2

here:

else: = 0

what is =0 doing?


#3

gives the same error

File “python”, line 8
else: =0
^
SyntaxError: invalid syntax


#4

that makes sense, i only put that line of code there to indicate what line of code i was talking about

then i asked you a question:

which you didn’t answer.


#5

sorry you understand your question differently, but I think I’m on the right track back.
Because of your question, thank you!


#6

that was the point of my question :wink:


#7

Another question about the same assignment. The code gives the correct answer only the induction remains wrong?
original = raw_input(‘Enter a word:’)
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
if len(original) > 0 and original.isalpha():
print new_word


#8

thinking through your program, what would be the logic steps? I think it should be:

  1. get user input
  2. check if user input is valid
  3. if valid, do the string manipulation.
  4. else, inform the user of invalid input

if look at your program, the order 1, 3, 2. And step 4 seems to be missing altogether. And step 3 is done if even string isn’t valid