title: Why do I get SyntaxError when running a Python 3 script on Visual Studio Code?
body: <p>I was progressing through the exercises on <strong>Zed Shaw's Learn Python 3 the Hard Way</strong> but then on Exercise 6, I encountered a syntax error, which I am not able to figure out. I tried searching on Google, StackOverflow (other posts), but none of the solutions mentioned work for me.</p>
  <p>The snippet of the code that is throwing this error is:</p>
  <pre><code>types_of_people = 10
  x = f&quot;There are {types_of_people} types of people.&quot;
  print(x)
  </code></pre>
  <p>I am using Visual Studio Code 1.38.1, with Python 3.7.4 64-bit on macOS Mojave 10.14.6.</p>
  <p>Surprisingly, I executed the code three different ways, and two of the methods showed the same error, but a third method actually executed the code successfully. I am trying to understand why VSCode is not able to execute the python script. Any help would be highly appreciated.</p>
  <h3><strong>Method 1</strong></h3>
  <p>Used the standard way to execute python script in VSCode:</p>
  <p>This method gave the SyntaxError. The error output is:</p>
  <pre><code>[Running] python -u &quot;/Users/e139177/Documents/Programming/Learn-Programming/tempCodeRunnerFile.py&quot;
  File &quot;/Users/e139177/Documents/Programming/Learn-Programming/tempCodeRunnerFile.py&quot;, line 2
  x = f&quot;There are {types_of_people} types of people.&quot;
  SyntaxError: invalid syntax
  [Done] exited with code=1 in 0.035 seconds
  </code></pre>
  <p>Screenshot 1 shows the error in VS Code.</p>
  <p><img src="https://i.stack.imgur.com/pH8Jh.png" alt="VSCode Standard Run Command" /></p>
  <h3><strong>Method 2</strong></h3>
  <p>Used &quot;Run Python file in terminal&quot; option in VS Code.</p>
  <p>This method executed the script successfully, and the output generated is:</p>
  <pre><code>KENMACC02XG4AEJHD2:Learn-Programminge139177$/usr/local/bin/python3/Users/e139177/Documents/Programming/Learn-Programming/Exercise6.py
  There are 10 types of people.
  KENMACC02XG4AEJHD2:Learn-Programming e139177$
  </code></pre>
  <p>Screenshot 2 shows the successfully executed script in VS Code terminal.</p>
  <p><img src="https://i.stack.imgur.com/0mshY.png" alt="VSCode Terminal Output" /></p>
  <p><strong>Method 3</strong></p>
  <p>Used MacOS terminal to directly execute the python script, without using VSCode.</p>
  <p>This method also gave the same SyntaxError. The error output is:</p>
  <pre><code> KENMACC02XG4AEJHD2:Learn-Programming e139177$ python Exercise6.py
    File &quot;Exercise6.py&quot;, line 2
      x = f&quot;There are {types_of_people} types of people.&quot;
                                                        ^
  SyntaxError: invalid syntax
  KENMACC02XG4AEJHD2:Learn-Programming e139177$
  </code></pre>
  <p>Screenshot 3 shows the successfully executed script in VS Code terminal.</p>
  <p><img src="https://i.stack.imgur.com/Lmtro.png" alt="MacOS Terminal Output" /></p>
  <p>I am not sure why the script executes successfully when run within the VSCode terminal, but it does not do so when executed using VSCode's &quot;Run&quot; command, or when executed within the macOS terminal directly.</p>