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

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

Python, 2 lines
1
2
for char in somestring:
    do_something(char)

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

1 comment

Roberto Amorim 20 years 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.