On 08/02/2011 11:20, tee chwee liong wrote:
hi all,
i have a function which returns a string. for eg: X='101110'. i want
to search for 0 and highlight the location.
i am thinking of defining X as a list. but how can i split 101110 as
there are no spaces in between? i'm thinking if i can put it into a
list: X=['1','0','1','1','1','0'], then i can use index to point out
the locations of the 0. pls advise.
i'm using Python2.5 and WinXP.
thanks
tcl
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
In Python strings are lists of characters so you can use indexes already.
You can look at the .find() function to return you index numbers for the
location of your search criteria, it only returns the first within your
parameters, but you can create your own function utilising it to return
all occurrences.
--
Kind Regards,
Christian Witts
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor