0

I am attempting to parse through a string to look for all slashes in the string but cannot close out the parenthesis.

    for i in string:
          if i == '\':
                do_something

It wants to treat the \' as one character. Is there a way to nullify that?

echo3
  • 111
  • 1
  • 11

1 Answers1

8

You need to escape the backslash character with another backslash.

for i in string:
      if i == '\\':
            do_something
Frank Bryce
  • 8,076
  • 4
  • 38
  • 56