10: Ending up


#1



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

It says the syntax for line 12 (were else: is) is invalid


This honestly makes no sense, it should work!


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)]
new_word = new_word[1:]
print new_word
else:
    print 'empty'


#2

The link takes me to my exercise. Although it's helpful for us to have the link, you need to paste your code as well.


#3

I edited it to include the code.


#4

You're missing a = sign for your new_word [1:len(new_word)] And you don't need to set new_word again after the if statement.


#5

Now line 9's syntax isn't working after adding the =. This is so confusing.


#6

That's because what you're setting it equal to isn't right.You can set new_word = [1:len(new_word)] You have to set new_word = new_word[1:len(new_word)] You're basically taking the first letter out of new_word.

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 = new_word[1:len(new_word)]
else:
    print 'empty'

#7

It now gets me to the next part, yet it doesn't translate anything. Why?


#8

It is translating. It's storing it in the new_word variable. If you add print new_word at the end of your if statement, it will print. I just added it in the next "lesson" so it didn't show up in this code.


#9

Oh OK. Thank you very much!


#10

Thanks a bunch!!
That really helped me!!:grinning:


#11

Hi, 'sorryicouldntthinkof', when did you post this?:confused:


#12

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