10.Ending Up Syntax Error


#1

File "python", line 10
else:
^
SyntaxError: invalid syntax


#2

Try this code instead: :slight_smile:

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
newword = word + first + pyg
newword = newword[1:len(newword)]
print original
else:
print 'empty'

#3


#4

Refresh the page and write this code, it must work:

pyg = 'ay'

original = rawinput('Enter a word:')
word=original.lower()
first=word[0]
newword=(word+first+pyg)
newword=newword[1:len(newword)]
if len(original) > 0 and original.isalpha():
print newword
else:
print 'empty'

#5

It did for me. Thank you!


#6

One more question...
Can we delete the second line of newword?
it seems that we can still run out without it


#7

Or you only had to indent your print before the else:...