10/11 glitch?


#1

This is my code
pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
print original
word=original.lower()
first=original[0]
new_word=word+first+pyg
new_word[1:len(new_word)]
else:
print 'empty'

my error is this Oops, try again. Your code did not run to end - see the console window for the error message. This is console window: File "python", line 11
else:
^
SyntaxError: invalid syntax


#2

try this

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

or

Try it here on Labs


#3

I was having a similar problem with my code bellow. I tried your solution and it still gave me a syntax error focusing the semicolon in the "print [len(new_word)]

print "Welcome to Pig Latin"

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`
print [1:len(new_word)]
else:
print 'empty'


#4

I see the error now. take a look at your code on this line

new_word = word + first + pyg`

see how you have that little backquote at the end of pyg take it out and it should word

and remember you should do

print new_word[1:len(new_word)] # not print [1:len(new_word)]

#5

Tried it and got error message:

Oops, try again.
first should contain the first letter of word.

#6

can you put your code here


#7

I tried exactly what you have down, but I always keep getting the error message "looks like it printed the correct translation of "[word]", but make sure to set new_word equal to the slice as well."

When I skipped the lesson, it said that everything was right! What's messed up?


#8

@first_timer_fred

try this and see if it works

original = raw_input("Enter word:")# Start coding here!
if len(original) > 0 and original.isalpha():
    print original[1:]+original[0]+"ay"
else:
    print "empty"

#9

i get the same message about new word equal slice. That doesn't work for me either