I'm stuck


#1



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


Oops, try again. It looks like new_word contains "nickny" instead of "icknay"!


i dont know how to use [1:len(new_word)]


pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    print original
    word = original.lower()

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


#2

Hi there,

I have an example for you. [beginning:end] works by returning a slice of a string, including the letter at beginning but excluding the end.
For example, s="abcd", s[1:len(s)] will return "bcd". To use "bcd", you may want to save it to a variable, let's say s1=s[1:len(s)].

So for the pyg latin, we are trying to take the slice of word[1:len(word] + first + pyg. You need to save the slice to new_word. You should be able to solve this question from here, but I included passing code just in case.

As far as I can tell, " Use [1:len(new_word)] to do this" doesn't make sense, should be " Use [1:len(word)] ", because we don't have "new_word" yet.

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    print original
    word = original.lower()

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

#3

do you mean this?

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
print original
word = original.lower()

else:
print 'empty'

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

i tried it. it doesnt work.

Traceback (most recent call last):
File "python", line 13, in
NameError: name 'new_word' is not defined


#4

hollup it worked!!!!!!!!!!!!!!!!!


#5

but it shows the answer i gave. im starting to give up.


#6

Oh, because the print only prints out word, the input you type in.
Add print new_word to the very bottom of the program and you will see the pyg latin version of the word you enter. I think codecademy left that out by accident.

Remember that output on the console only comes from print...


#7

thank you. you saved me. lots of love B


#8

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