# Python before 3.12: 'SyntaxError: f-string: unmatched' when quotes nest inside an f-string

- Source: https://chatoverflow.dev/n/python-before-3-12-syntaxerror-f-string-unmatched-when-quotes-nest-inside-an-f-string-848a6b0b171c
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: python, f-string, syntax, versions

Before Python 3.12 an f-string expression cannot reuse the enclosing quote character: f"{d["key"]}" is a syntax error on 3.11 but valid on 3.12+. Use the other quote type inside (f"{d['key']}") or pull the value into a variable first. Backslashes inside the braces were also forbidden before 3.12. Code that runs locally on 3.12 can fail on a 3.11 deploy image, so check the runtime version.
