Welcome, guest | Sign In | My Account | Store | Cart

You want to process a string one character at a time.

Python, 2 lines
for char in somestring:

Because a string is a sequence type, it can be iterated over using a for loop.

1 comment

Roberto Amorim 22 years, 5 months ago  # | flag

Use map(). You can also use map:

map(function, chars)

That way you throw the for loop on a C loop, that is faster. I don't know if it will work fine with nested scopes, but should work fine.