Python Forum

Full Version: what's really wrong with this f-string?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
what's really wrong with this f-string? the quotes look right so it must be the backslash.
Output:
>>> a=432 >>> s=f'{a} "\{"' File "<stdin>", line 1 SyntaxError: f-string: unterminated string >>>
In the format() syntax, one escapes curly braces by doubling them. It should probably be s=f'{a} "{{"'