Getting syntax error with f strings in VS Code and python

I’m trying to print an f string with python in VS Code like so:

name = "John Doe"

print(f"name is {name}")

I’m using python 3.7.6
Screen Shot 2020-02-10 at 1.57.17 PM

What have I maybe missed setting up my environment?

The f character is used to signal that it is an f string, new in python 3.6 see:
https://cito.github.io/blog/f-strings/
The code is correct.

1 Like

there is no problem with your syntax i tried it and it worked just fine

That’s whats so frustrating, it should work but I get this error:

Screenshot (217)

Screenshot (219)
try this

Thanks that does work. But I also just figured out that in the VS Code terminal I need to use

python3 filename.py

rather than what I was doing which was

python filename.py
1 Like