16

The following code:

a = 0
b = f'{"c": {a}}'

throws the error: ValueError: Sign not allowed in string format specifier How to fix it?

0

1 Answer 1

20

Escape the braces like this.

>>> f'{{"c": {a}}}'
'{"c": 0}'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.