Iteration over strings

Robert Dailey rcdailey at gmail.com
Tue Jul 31 13:55:44 EDT 2007


Hi,

I have the following code:

str = "C:/somepath/folder/file.txt"

for char in str:
    if char == "\\":
        char = "/"

The above doesn't modify the variable 'str' directly. I'm still pretty new
to Python so if someone could explain to me why this isn't working and what
I can do to achieve the same effect I would greatly appreciate it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070731/716298eb/attachment.html>


More information about the Python-list mailing list