[issue46305] SyntaxError when using dict key in fstring

Nikita Sobolev report at bugs.python.org
Sat Jan 8 03:39:36 EST 2022


Nikita Sobolev <mail at sobolevn.me> added the comment:

Can you please try this:

```
dict1 = {
        "key1": "test"
        }

print(dict1["key1"])

print(f"key1 is {dict1['key1']}!")
```

The problem with your code is that `dict1["key1"]` used the same quotes as `f""`.

----------
nosy: +sobolevn

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46305>
_______________________________________


More information about the Python-bugs-list mailing list