The pyg latin code i wrote works but its not accepting it?


#1

https://www.codecademy.com/courses/learn-python/lessons/pyglatin/exercises/ending-up?action=lesson_resume&link_content_target=interstitial_lesson

It shows in the console correctly how the word should be written in pyg latin, but it has the error ‘It looks like you printed the correct translation of “cat”, but make sure to set new_word equal to the slice as well.’ … this is the code i wrote:
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 new_word[1:len(new_word)]
else:
print ‘empty’

I’m not really sure what it meant by 'make sure to set new_word equal to the slice as well", because i thought that’s what i did when i wrote new_word[1:len(new_word)] …i’m not sure how to fix this and it’s not letting me move on until i do. I know i could continue if i copy and paste the code from somewhere, but i’d like to know what’s wrong with it first.






#2

Error:

make sure to set new_word equal to the slice as well

look at here

new_word[1:len(new_word)]

you did a slice of new_word here.right? so you have to set this value to the variable named new_word.
now print the variable instead of writing the whole slice again.


#3

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