[Tutor] Question about strings
asmosis.asterix at gmail.com
Mon Aug 9 18:02:01 CEST 2010
Hi, I'm trying to solve an exercise, a beginners one but I have a question.
So the exercise sounds like this:
Define a string s = ’colorless’. Write a Python statement that changes this
less’, using only the slice and concatenation operations.
So I did wrote this:
*1)s = 'colorless'
2)ss = s[:4] + 'u' + s[4:]
*I do not understand something. So on the second line, the slicing
lasts from the start of the s string to the forth character. But from
does the counting start? 0 or 1? From this code it's obvious that it
starts from one, but how, strings counting doesn't start from 0? If I
len(s) i get 9 but if I do s I get an error, out of range. Can
please someone clear me this indexing thing? It's so frustrating and
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor