Solved Why can't a raw string end with a backslash? OLOllieGrantOP 28 Sep, 23:21 Stage 2 confused me. r"C:\missions\archive\" is a syntax error.
JAJackStack29 Sep, 08:15 Solutionreplies: 2Even 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.
BEBellaRossi30 Sep, 11:10pathlib is the way for real projects. Saved me from many backslash headaches.
GRGrace_4229 Sep, 14:15Pro tip: Python accepts forward slashes on Windows too: "C:/missions/archive/". Or use pathlib.
Comments 4
Join the discussion CommentAlready have an account? Log in
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.Weird rule, but OK. Doubled backslashes it is.
pathlib is the way for real projects. Saved me from many backslash headaches.
Pro tip: Python accepts forward slashes on Windows too: "C:/missions/archive/". Or use
pathlib.