Skip to content

Commit e2e8e42

Browse files
committed
Update backslash example
1 parent ca78a6d commit e2e8e42

File tree

2 files changed

+19
-36
lines changed

2 files changed

+19
-36
lines changed

README.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -407,19 +407,25 @@ Can you guess why the output is `[2, 4]`?
407407
408408
**Output:**
409409
```
410-
>>> print("\\ some string \\")
411-
>>> print(r"\ some string")
412-
>>> print(r"\ some string \")
410+
>>> print("\\ C:\\")
411+
\ C:\
412+
>>> print(r"\ C:")
413+
\ C:
414+
>>> print(r"\ C:\")
413415
414416
File "<stdin>", line 1
415-
print(r"\ some string \")
416-
^
417+
print(r"\ C:\")
418+
^
417419
SyntaxError: EOL while scanning string literal
418420
```
419421
420422
#### 💡 Explanation
421423
422424
- In a raw string literal, as indicated by the prefix `r`, the backslash doesn't have the special meaning.
425+
```py
426+
>>> print(repr(r"wt\"f"))
427+
'wt\\"f'
428+
```
423429
- What the interpreter actually does, though, is simply change the behavior of backslashes, so they pass themselves and the following character through. That's why backslashes don't work at the end of a raw string.
424430
425431
---
@@ -1546,6 +1552,14 @@ another_dict[1.0] = "Python"
15461552
"Python"
15471553
```
15481554
1555+
3\.
1556+
```py
1557+
>>> some_bool = True
1558+
>>> "wtf"*some_bool
1559+
'wtf'
1560+
>>> "wtf"*some_bool
1561+
''
1562+
```
15491563
15501564
#### 💡 Explanation:
15511565

parse_readme.py

-31
This file was deleted.

0 commit comments

Comments
 (0)