echo3
echo3

Reputation: 131

'\' wont close quotes

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?

Upvotes: 0

Views: 53

Answers (1)

Frank Bryce
Frank Bryce

Reputation: 8446

You need to escape the backslash character with another backslash.

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

Upvotes: 8

Related Questions