
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Why do backslashes appear twice while printing in Python?
Backslash is an escape character. It is used to escape characters like quotes, double quotes, new line, etc. When we print a string containing a backslash, we see it twice because a backslash is also needed to escape itself. It means that we are telling the interpreter that this backslash is to be used as a backslash only and not as an escape character. For example,
print 'hello \ John\'s friends'
OUTPUT
"hello \ John's friends"
- Related Articles
- How do backslashes work in Python Regular Expressions?
- Avoiding quotes while printing strings in Python
- Why do teeth come twice?
- Why there is not do...while loop in Python?
- Elements that appear twice in array in JavaScript
- Reduce decimals while printing in Arduino
- What Does while true do in Python?
- Why do people mostly wear black while mourning?
- Multi-Line printing in Python
- How to stop printing messages while loading a package in R?
- Why does the result of id() appear to be not unique in Python?
- Printing to the Screen in Python
- How to emulate a do-while loop in Python?
- Why do birds fly on V shape in the group while travelling?
- while and do-while in Dart Programming

Advertisements