PygLatin correct translation, yet error


#1


https://www.codecademy.com/courses/python-beginner-2W5v7/1/4?curriculum_id=4f89dab3d788890003000096#

The code seems to run properly, but I get the error message:

"Oops, try again. It looks like you printed the correct translation of "cinema", but make sure to set new_word equal to the slice as well."


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


#2

Your error message pretty much spells it out for you, but here's a hint.

Notice how you don't store this line of code under any variable. And the error message says:

Hmmm....I wonder what you should do. I'm sure you can figure it out now. :slight_smile:


#3

Yep, I think I've tried what you're suggesting.

When I set new_word equal to the slice like this :

new_word = [1:len(new_word)]

the code no longer runs and I get a syntax error in the console :

File "python", line 9
new_word = [1:len(new_word)]
^
SyntaxError: invalid syntax

is this the solution you were getting at? Any idea why the code won't run anymore?

Thanks


#4

NM GOT IT

new_word = new_word[1:len(new_word)]

#5

Good job! :slight_smile:


#6

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