Problem with Formatted Strings in VsCode

Hi all,
I am working through Mosh’s python code and I am using VScode so I can follow along the same as the video.
Everything has been working fine, until I have come to the lesson on formatted strings.
For instance here is the code

first = “Joe”
last = “Blogs”
full = f"{first} {last}"

But when I run it, I get a Syntax Error
Can anyone help me out here


You are correct

It appears to of run for you!
This is what is appearing for me!

Looks like you’re using a rather old (prior to 3.6) version of python. Run python --version to be sure.

Hi, I’m facing the same problem with formatted string and I got the same syntax error.
Can anyone help me… Thank you

Thank you Sam indeed for the help, however still I did not get you because I’m using the updated version of Python 3.9 as it appears in the image attached below. Could you clarify the solution?

All the best


Screen Shot 2021-04-15 at 11.21.22 PM.png

The screenshot just shows that VSCode found an installation of Python 3.9.2 but the version you actually run seems to be older since it doesn’t understand formatted strings yet.

I was the same but I found out what fixed it is to go to:
View > Command Palette > Python: Select Interpretor and make sure you select the latest version ie 3.9.2. Re-save the file and run again and it should work. Are you running a mac? if you are like me, it seems it automatically defaults back to 2.7.16 on restart and I cant work out how to make the 3.9.2 be the constant default. But, that should fix your issue.