Pyg Latin Ending Up Slicing Syntax Issue


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)]
    print 'empty'


Where is the object that is to be sliced?

object[ ... ]

Hint, new_word is that object.


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


[] 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:


new_word = new_word[ ... ]

(replace ... with your code)


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


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