Python 3.7.0 F-strings

Why print(f"{a + ‘\’}\") create Exception?

“Why print(f”{a + ‘\’}\“) create Exception?”

SyntaxError: f-string expression part cannot include a backslash

Try this instead:

a = 'something'
print(f"{a + chr(92)}\\")
1 Like