Syntax error no matter what I do


#1

Hey guys -
Im in the middle of doing the pig latin translator, on step 10/11.
I keep getting this syntax error:
“File “python”, line 11
else: print “Unable to process request”
^
SyntaxError: invalid syntax”

And its really annoying. Its like Im stuck even though I feel like Im doing everything right.
Heres my code:

pyg = ‘ay’

original = raw_input(‘Enter a word:’)

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
new_word = word + first + pyg
s = new_word
print s[1:len(new_word)
else: # <----- errored code
print “Unable to process request”

Any help is much appreciated :slight_smile:


#2
else: print “Unable to process request”
^
SyntaxError: invalid syntax”est”

else and print shouldn’t be at same line. you need proper indentation like you did for if.

to show indentation here what you’ve done in your code do the following

  • select the whole code
  • click on the </>

#3

Thank you! Figured it out :smiley:
appreciate your help


#4

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