like a "for loop" for a string

Grzegorz Staniak gstaniak at wp.pl
Sun Aug 17 22:01:40 CEST 2008


On 2008-08-17, Alexnb <alexnbryan at gmail.com> wroted:

> Basically I want the code to be able to pick out how many strings 

What do you mean by "string"? 

foo = "abc abc cde abc ijk abc cde abc"

"foo" is one "string". If you want substrings, specify what kind of substrings 
you mean. All occurences of "abc", for example. 

> there are
> and then do something with each, or the number. When I say string I mean how
> many "strings" are in the string "string string string non-string string"

Do you mean something like "count and return all occurences of the substring 
'abc' in foo"? Looks like you should use the re module.

GS
-- 
Grzegorz Staniak <gstaniak _at_ wp [dot] pl>



More information about the Python-list mailing list