Can you show us the entire error message will all it’s accompanying
lines? Also, what version of Python are you running?
To use f-strings (the f"..." form) you need Python 3.6 onwards.
To give hope, here’s your code running in Python 3.10 here in IDLE (the
interactive Python prompt):
Python 3.10.6 (main, Jan 1 2024, 19:58:15) [Clang 15.0.0
(clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> first_name = "ada"
>>> last_name = "lovelace"
>>> full_name = f"{first_name} {last_name}"
>>> print(full_name)
ada lovelace
Do not put this inside the source code file (remove it if it’s already there). Instead, type it in a terminal/shell window, after saving the file. (Exactly what operating system are you using?)
Hey everyone, thanks so much for the prompt replies. I tried opening a new file (I’m using a Mac with the latest version of python) and typed in the same code under a different save file and it didn’t work again. Exact same error code.
THEN I tried the code in sublime text editor and it worked. I still have no idea why it’s not working in vis studio though =/
I put visual studio python command syntax errorinto a search engine and the first result was:
which appears to be the exact issue you describe.
If you know what’s in your source code file and you’re getting an error message that tells you about something that isn’t in your source code file, you should suspect the IDE.