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}"
print(full)
But when I run it, I get a Syntax Error
Can anyone help me out here
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?
Thanks…
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.
Hi, I was running into the exact same problem…
… trying everything you suggested above, I still could not fix the problem.
Can anybody help me?
I am using Python 3.9.6 64-bit
I had the same issue on Mac and I have sorted it with the following:
1: settings
2: in the search bar type: code-runner.executorMap
3: click Edit in settings.json
4: after the last code type a comma and press enter
5: on the next line type as follow “code-runner.executorMap”
6: lots of new codes will be displayed
7: amend the the python code (on mine it was on line 14) showing as
“python”: “python -u”, as follow:
“python”: “python3”,
8: save and exit
After this amendment, the formatting string started to work.
For help refer to “Lesson 9” of Getting Started. It is not the same on newer versions but the above should help.