Ending Up lesson question, multiple! [SOLVED]


#1

LESSON EXAMPLE:
s = "Charlie"

print s[0]

will print "C"

print s[1:4]

will print "har"

using s[1:4]. This returns everything from the letter at position 1 up till position 4.

Question 1, har in Charlie is letter 1,2,3. Why did it say position 1 up till position 4, shouldn't "l" also be included?
Question 2, I follow the instruction to "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." and console returns "Oops, try again. It looks like you printed the correct translation of "larry", but make sure to set new_word equal to the slice as well." What am I missing here?

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
    print new_word[1:len(new_word)]
    print original
else:
    print 'empty'


#2

1) Specifying ranges can be done with both inclusive and exclusive end-points, one just has to pick something and use that
2) It's telling you what you're missing, unclear why that information isn't enough


#3

A post was split to a new topic: Ending up


#4

Hello guys, im new here, and mine is the same as his code, but when I click save & submit code, returns me the message: ''Oops, try again. It looks like you printed the correct translation of "house", but make sure to set new_word equal to the slice as well.''

Any help?


#5

please make a new topic with code and error message so we can help, we can't help you like this


#8

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