Pyg Latin Ending Up Slicing Syntax Issue


#1


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

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


Replace this line with your code. 

pyg = 'ay'

original = raw_input('Enter a word:')

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


#2

Where is the object that is to be sliced?

object[ ... ]

Hint, new_word is that object.


#3

I am attempting to redefine new_word excluding the first letter of new_word. I don't understand what's wrong with my syntax.


#4

[] by itself is a list, not a slice.

[1:len(new_word)] will raise a syntax error.

To take a slice of a string, we need to specify the name of the object (string) that we are slicing:

string[:]

new_word = new_word[ ... ]

(replace ... with your code)


#5

Ah, I realize my mistake. Thanks for the help.


#6

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