Question question regarding f-strings and expressions in Python 3.
The Python documentation states clearly that:
Formatted string literals (also called f-strings for short) let you include the value of Python expressions inside a string by prefixing the string with f or F and writing expressions as {expression}.
A valid expression is: {A = "A"} but this doesn't work:
>>> print(f'{A = "A"} {A}')
File "main.py", line 3
print(f'{A = "A"} {A}')
^
SyntaxError: f-string: expecting '}'
What am I doing wrong here? My expression is valid. I'm sure I'm misunderstanding the documentation so if someone can clarify it would be a great help.
Thanks.
{A = "A"}[...] My expression is valid." assignment is not a valid python expression.