What is wrong with my code?



File "python", line 9
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():
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = [1:len(new_word)]
print original
print 'empty'


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.


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