Task is achieved but error still pops up


#1


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

this is the error message : Oops, try again. first should contain the first letter of word.


original = raw_input('Enter a word:')
word=original.lower()
first=s[0]
s="Charlie"
new_word=s + word + first
if len (new_word) > 0 and new_word.isalpha():
    print s[0]
    print s[1:4]
else:
    print 'empty'


#2

If you read your code you'll find that you're doing things out of order
Also, what's special about the string "Charlie"? If you refer to the description of what your code should be doing, I don't think it'll say anything about that particular string


#3

fair enough, im going to re do it. thanks tho


#4

I'd suggest fixing it instead. A start would be to read it and manually execute it - that way you'll encounter the same things and you can compare to what's supposed to happen. Of course, you'll probably want to read over the instructions again to make sure you know what is supposed to happen


#5

thanks for the advice


#6

hi ionatan

i have been trying to figure it out but i managed to slice it but for some reason i cant understand where to include the [1:len(new_world)], could you please hint me thanks

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

code
original = raw_input('Enter a word:')
word=original.lower()
first=word[0]
sec=word[1:4]
new_word= first+sec
if len (new_word) > 0 and new_word.isalpha():
print new_word
else:
print 'empty'


#7

Try figuring out how slicing behaves first and what the syntax is - with that you can refer to what the desired effect is and work out how where to put that. If what the instructions describe isn't enough, then go search for other resources, for example this https://stackoverflow.com/questions/509211/explain-pythons-slice-notation

Note that you are already using slicing in your code, and it seems oddly specific too, where does the number 4 come from? You need to motivate why each thing is correct, if you can't, then keep finding out more about that something, read about it or experiment with it with simpler usage with no other code


#8

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