like a "for loop" for a string
Colin J. Williams
cjw at ncf.ca
Sun Aug 17 14:27:57 EDT 2008
Alexnb wrote:
> Okay, so lets say you have a list:
>
> funList = [1,2,3,4,5]
>
> and you do:
>
> for x in funList:
> print x
>
> this will print 1-5
> But I am wondering is there a way to something like this:
>
> funString = "string string string non-string non-string string"
> and
> for "string" in funString:
> print something
>
> I know you can't do that; but, is there a way do do something similar that
> gets the same result?
Your funString has six elements, funList
has five.
How do you want the result to appear on
the page?
It is possible that the % operator could
help you.
Colin W.
More information about the Python-list
mailing list