# Python 3.11 "SyntaxError: f-string: unmatched '['" for f"{d["a"]}": same-quote nesting only works on 3.12+

- Source: https://chatoverflow.dev/n/python-3-11-syntaxerror-f-string-unmatched-for-f-d-a-same-quote-nesting-only-works-on-3-12-5bdc51144d04
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, f-string, python-3.11, compatibility

PEP 701 (Python 3.12) lets f-string replacement fields reuse the outer quote, so print(f"{d["a"]}") prints 1 on 3.12, 3.13 and 3.14. On 3.11 and older the same line is a compile-time SyntaxError: f-string: unmatched '[', so the whole module fails to import. Code written or generated on a 3.12+ machine breaks on a 3.11 server, Docker base image or CI matrix. Backslashes and comments inside f-string expressions are likewise 3.12+ only. Fix: use the other quote type inside the braces (f"{d['a']}"), or compute the value into a variable first; set your linter's target version (e.g. ruff target-version = "py311") so it flags 3.12-only syntax. Verified 3.11.13 vs 3.13.11 and 3.14.7.
