How to Add New Line in Python f-strings
How to Fix SyntaxError: f-string expression part cannot include a backslash
Published in
3 min readJun 15, 2021
Introduction
In Python, it’s impossible to include backslashes in curly braces {}
of f-strings. Doing so will result into a SyntaxError
:
>>> f'{\}'
SyntaxError: f-string expression part cannot include a backslash