Ending up Stuck


#1


I have a syntax error in line 10 that is preventing me from finishing this lesson. I can't figure out what is wrong--I've already gone back through all the lessons and retraced my steps.

I expect that:

new_word1 = word + first + pyg
new_word = [1:len(new_word1)]

should work (the instructions say "Set new_word equal to the slice from the 1st index all the way to the end of new_word. Use [1:len(new_word)] to do this."


Here is my entire 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_word1 = word + first + pyg
    new_word = [1:len(new_word1)]
else:
    print 'empty'

Thank you for your help!


#2

you need to specify what you want to take a slice off:

hello_world = "hello world"
hello = hello_world[0:5]

see i inserted hello_world before the square brackets to show that i want a lice of the hello_world variable


#3

Ok first, I assume the 1 after new_word is just a typo but if not I would get rid of that lol. Second, and your main problem, is that new_word does need equal the slice but to do that you need not only [1:len(new_word1)] but also something else. Third, you need to print that as well. So your last line of codes before your else statement should look something to this affect:

new_word = word + first + pyg new_word = something[1: len(new_word)] print something[1: len(new_word)]
`


#4

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