10.Ending Up oops try again( new_word equal to slice?)


#1



Hi all, as you see below i had a problem with my code.. i don't know exactly what went wrong.. But it gave me an try again message. I looked at the hint and changed a litte but still gives the same message. Can someone help me out?!?!

The instructions were as follows:
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.


Oops, try again. It looks like you printed the correct translation of "justin", but make sure to set new_word equal to the slice as well.


pyg = 'ay'

original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
new_word = word + first + pyg


if len(original) > 0 and original.isalpha():
    print new_word[1:]
else:
    print 'empty'


#2

This three lines should be inside the if statement,

Basically what the hint is telling you to do is declare another variable new_word and store this slice inside it,

also you'll need to add first and pyg to that slice,

first + pyg


#3

I was able to manage it like this:
pyg = 'ay'

original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
new_word = word[1:len(word)] + first + pyg

if len(original) > 0 and original.isalpha():
print new_word
else:
print 'empty'


#4

i thought we had to put these statements inside of the if statement????


#5

It worked like that, and I wasnt able to put it in the if statement.


#6

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