"tee chwee liong" <tc...@hotmail.com> wrote
i have a function which returns a string. for eg: X='101110'.
i want to search for 0 and highlight the location.
I'm not sure what you mean by highlight the location.
Is it a GUI? Are you colour coding the characters?
i am thinking of defining X as a list.
You shouldn't need to, you can treat the string as a
sequence directly
indexes = [i for i, c in enumerate(X) if char == '0']
Will give you the list of indexes you need.
How you use that to highlight the zeros will depend
on your UI I guess.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor