Code doesn't cut the first letter


#1



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


The code doesn't cut the first letter


pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha() :
    print original
    word = original.lower() #Shelo=shelo
    first = word[0] #s
    new_word = word+first+pyg #shelo+s+ay=shelosay
    s=new_word
    s[1:len(s)] 
    
    print s
    
    
    
else:
    print 'empty'

Enter a word: shelo
shelo
shelosay
None


#2

Ok so you have fallen into a trap that many people fall into with this lesson. Believe it or not you don't actually have to use s to solve this lesson! Yes, the example is misleading but we can fix this! The first part of your code is excellent! Well done on that! Now lets take a look at the S part.
1. 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

Therefore, you are going to use [1:len(new_word)] in both your equal to and your print.
Instead of s you are going to use new_word to equal something[1:len(new_word)]
Then you are going to print something[1:len(new_word)] We do this because it sets new_word equal to the slice from the first index to get the letter change in the word so that the pig latin translation will be completed. Your else statement is fine so hopefully this fixes your problem!
All in all:

new_word= word + first + pyg
    new_word = what[1:len(new_word)]
    print what[1:len(new_word)]
else:
    print 'empty'

#3

Thanks a lot , i fixed it so it looks like :
word = original.lower() #Shelo=shelo
first = word[0] #s
new_word = word+first+pyg #shelo+s+ay=shelosay
new_word = new_word[1:]

print new_word

Enter a word: shelo
helosay
None


#4

Ok you are very close! Remember [1:len(new_word)] has got to be used in full! I think you know where to put it both times :smiley:


#5

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