Ending up


I'm so confused about the letter count

For s = "Charlie"

if s[0] = C

then why is s[1:4] = har

when h = 1, a = 2 r = 3???

Is it because s[1] removes the letter from the string? so after H is taken out



lets do this example:


there are two values here: start value (1) and stop value (4), for slices goes that the stop value is not included. so slice till values lesser then 4 (<) not lesser or equal to 4 (<=)


When slicing, Python doesn't include the starting point - just everything AFTER that starting point, until the defined end. For example, if the following code were to run:

sup = "Infinity!!!"
print sup[1:5]

The output in Python would be:



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