I have just started reading the 2nd edition of Python Crash Course, and just in case someone has the book, I am on the subsection "Using Variables in Strings" in chapter 2.
The problem is, when I enter
first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"
print(full_name)
on Sublime Text, it is supposed to output
ada lovelace
but instead, I receive an error reading
File "/Users/davidjiang/Code/Python/python_work/full_name.py", line 3
full_name = f"{first_name} {last_name}"
^
SyntaxError: invalid syntax
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/davidjiang/Code/Python/python_work/full_name.py"]
[dir: /Users/davidjiang/Code/Python/python_work]
[path: /Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
I have already checked that Sublime Text is running in python3.7 by inserting
{
"cmd": ["python3", "-u", "$file"],
}
into the build system Python3.sublime-build. My terminal also runs in python3.
I also made sure that my code didn't have any errors by finding and using this link explaining how to insert values into strings. Additionally, the book I am reading comes with a collection of online resources complementing the course, including the code written at the beginning. When I put it through python IDLE, the code worked out fine.
Can someone please explain why the code doesn't work on Sublime Text? Thanks in advance!
Edit: Apparently, my Sublime Text is running python2 instead of python3. As it seems that inputting the above code won't work, does anyone have any advice on how to change Sublime to python3?