7

So I just started using Python and I'm getting this weird bug in Visual Studio Code. I'm using F Strings and inside the editor, it says it's invalid syntax. enter image description here

Why does this have a red underline? It's apparently also invalid syntax even though the code does work correctly from the command prompt. enter image description here

The extensions I have enabled are Beautify, ESLint (the file is picking up as MagicPython down the bottom so I assume this doesn't affect it), MagicPython, Material Theme, Python, Visual Studio IntelliCode - Preview. Thanks! Neeron.

NeuronButter
  • 709
  • 1
  • 8
  • 24

2 Answers2

1

You need to change your Python interpreter to a version that supports f-strings.

  1. Click on the python version on the bottom right of your screen select python interpreter position

  2. Select a newer python interpreter on the dropdown box.

The error should be gone now.

Wet Feet
  • 4,435
  • 10
  • 28
  • 41
0

I just use the extensions called python and I meet the same question like that. the question I meet Just adjusting the version of python which is used by the extend can solve the problem.change this

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 16 '21 at 03:35