[Tutor] string delimiters
Cameron Simpson
cs at zip.com.au
Thu Jun 4 02:54:27 CEST 2015
On 03Jun2015 17:35, richard kappler <richkappler at gmail.com> wrote:
>Perhaps the better way for me to have asked this question would have been:
>
>How can I find the location within a string of every instance of a
>character such as ']'?
With the str.find method!
s = 'a]b]c'
pos = s.find(']')
while pos >= 0:
print("pos =", pos)
pos = s.find(']', pos + 1)
Obviously you could recast that as a generator funciton yielding positions for
general purpose use.
Cheers,
Cameron Simpson <cs at zip.com.au>
Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
- Haiku Error Messages http://www.salonmagazine.com/21st/chal/1998/02/10chal2.html
More information about the Tutor
mailing list