On Tuesday, January 14, 2014 4:05:27 PM UTC+5:30, Igor Korot wrote: > Hi, Rustom, > > > > On Tue, Jan 14, 2014 at 2:16 AM, Rustom Mody wrote: > > You want this? > > > >>>> test = "I,like,my,chocolate" > >>>> test.split(',') > > ['I', 'like', 'my', 'chocolate'] > >>>> test.split(',')[2:4] > > ['my', 'chocolate'] > > > Yup, thats it. > Now 2 and 4 - it's a starting point and ending point, right?
In python ranges are usually lo-inclusive hi-exclusive. Slices are one case of this See explanations: http://docs.python.org/2/tutorial/introduction.html#strings and http://stackoverflow.com/questions/509211/pythons-slice-notation Neat theoretical explanation http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html -- https://mail.python.org/mailman/listinfo/python-list