Reputation: 331
I have written the below python program.
var = '28'
express = "r'\b" + var + "\b'"
print(express)
I expected to get r'\b28\b'
but I am getting r'28'
.
I don't understand why. Can someone please help me with it? Besides var
is supposed to be a user input so I need to know some way to print express
correctly.
Upvotes: 0
Views: 60
Reputation: 781129
\b
is the escape sequence for backspace. If you want literal \b
in your result, use a raw string to prevent the escape sequence from being processed.
var = '28'
express = r"r'\b" + var + r"\b'"
print(express)
Upvotes: 1