0

Please note this code is directly from a python book (2nd edition python crash course by eric mathes). When I run the code, it does compile though the regular python idle 3.7.5. However when I try to compile the code through the atom editor, it does not compile.

I've installed many python packages for atom editor, including python snippits, python tools, run-python-simply. But this still doesn't seem to compile.

first_name = "Adam"
last_name = "Scott"
full_name = f"{first_name}{last_name}"
print(full_name)

File "/Users/Adam/Desktop/full_name.py", line 3
    full_name = f"{first_name}{last_name}"
                                         ^
SyntaxError: invalid syntax

2 Answers2

2

You can use f-string only after Python 3.6 (including) so better to check the version or you can use older method format() to achieve the same output.

first_name = "Adam"
last_name = "Scott"
full_name = "{0} {1}".format(first_name, last_name)
print(full_name)

Adam Scott
>>>
Deepak Dixit
  • 1,510
  • 15
  • 24
-1

I'm working through the same book. once in the correct directory for the script, type: python3 full_name.py

I had the same issue as you from typing just "python"

You prolly solved it long ago. Python 2.7 was running instead of python 3.x

-Andy

Andy
  • 1