General list index question


s = "Charlie"

print s[0]

will print "C"

print s[1:4]

will print "har"

Why does print s[1:4] har instead of harl since the letter "l" is the 4th index in the list

Replace this line with your code.

string[first_index_inclusive, last_index_exclusive]

string[0:0]    =>  ""

string[0:1]    =>  first character


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