Solved

Why can't a raw string end with a backslash?

OllieGrantOP

Stage 2 confused me. r"C:\missions\archive\" is a syntax error.

11

Comments 4

Join the discussion

Already have an account? Log in

  1. JackStack Solutionreplies: 2

    Even in a raw string, a backslash before a quote still "protects" the quote from ending the string. So the final \" doesn't close it. That's why the stage asks for a normal string with doubled backslashes instead.

    6
      1. BellaRossi

        pathlib is the way for real projects. Saved me from many backslash headaches.

        0
    1. Grace_42

      Pro tip: Python accepts forward slashes on Windows too: "C:/missions/archive/". Or use pathlib.

      0