Ending Up


#1



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


Oops, try again. It looks like new_word contains "hellohay" instead of "ellohay"


"ellohay" should be printed


pyg = 'ay'

original = raw_input('Enter a word:')

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


#2

new_word[1:len(new_word)] should equal something. Also, should print new_word[1:len(new_word)] instead of just new_word.


#3

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

This is the new error message. I'm not sure what to set it equal to


#4

Can you paste your updated code? I think I know what the problem is but I want to make sure!


#5

pyg = 'ay'

original = raw_input('Enter a word:')

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


#6

So to get new_word equal to equal the slice as well you just need to like before equal it to new_word so new_word = new_word[1:len(new_word)]


#7

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
#here was the print original we no longer need :wink:
word=original.lower()
first=word[0]
new_word = word[1:len(word)] + first + pyg
######its word because we are taking leters form the word (not the new_wordXD)
and countig from the second leter,thats whats 1 in[1:len...] for(first leter is 0,second 1...),and countig leters to the end,thats whats len for.And the we add the variable first and the variable pyg and then add print new_word####
print new_word
else:
print 'empty'

so basicly i just added [1:len(word)] to the WORD in >>> new_word = word+ first + pyg

so it ends up like this
new_word = word[1:len(word)] + first + pyg


#8


#9

instead what you did:
line 8....................new_word = word + first + pyg
line 9....................new_word[1:len(new_word)]
Do what i did:
line 8....................new_word = word[1:len(word)] + first + pyg


#10


#11

@irfansherani aperently this works too


So OPTION 2: IS TO change your line 9 from
line 9....................new_word[1:len(new_word)]
to
line 9....................new_word=new_word[1:len(new_word)]


#12

Lol 3XNew_world its just not normal but who cares XD


#13

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