Back
+10 XP
Concept

Raw Strings (r"...")

Fighting backslashes in Windows file paths is torture. Stick an `r` right in front of your quotes to declare a raw string:

python
path = r"C:\users\nike\documents"

# 29. Raw Strings (r"...") Fighting backslashes in Windows file paths is torture. Stick an `r` right in front of your quotes to declare a raw string: ```python path = r"C:\users\nike\documents" ``` The `r` tells Python: *"Disable all escape tricks. Treat backslashes as dumb, literal characters."*

Checkpoint

What does `print(r"Line1\nLine2")` output?

Practice

Print the literal text `Folder\new\test` without `\n` breaking it onto a new line, using a raw string `r"..."`.

Terminal
01
Tap code blocks below to assemble
Available Blocks