What is wrong with my code?


#1



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


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


python
Replace this line with your code.
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 original
else:
print 'empty'


#2

Treat [1:len(new_word)] as an index. You're now missing the list/string the index is referring to which is new_word. [1:len(new_word)] is a slice where you remove index 0 of your list/string.
So it is actually

new_word = new_word[1:len(new_word)]

And you would print new_word as well.


#3

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