I was following along with this course on creating the Pig Latin translator and as I am following along, suddenly my if/else statement stopped working. It kept giving me an error on the else line, saying:
File “python”, line 13
else: print “ok”
SyntaxError: invalid syntax
Here is my code:
pyg = 'ay' s = "Charlie" original = raw_input('Enter a word:') if len(original) > 0 and original.isalpha(): word = original.lower() first = word new_word = word + first + pyg new_word = new_word[1:] print new_word else: print "ok"
It works if I take out the else statement. I dont understand why the else part of this is messing this up, when I was able to use the else portion of this before I had to add all the extra variables within the “if” statement".