13

The following code:

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

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

cs95
  • 379,657
  • 97
  • 704
  • 746
indigo153
  • 1,021
  • 2
  • 10
  • 23

1 Answers1

16

Escape the braces like this.

>>> f'{{"c": {a}}}'
'{"c": 0}'
cs95
  • 379,657
  • 97
  • 704
  • 746