0

I started with this example:

cars = ['audi', 'bmw', 'subaru', 'toyota']

for car in cars:
    if car == 'bmw':
       print(car.upper())
    else:
       print(car.title())

I deleted this and moved on to a new example, within same py file:

requested_topping = 'mushrooms'

if requested_topping != 'anchovies':
    print("Hold the anchovies!")

After I click run on this second code, VS Code still prints the output for the cars example. What could be the matter?

rioV8
  • 24,506
  • 3
  • 32
  • 49
Alfie
  • 3
  • 2

3 Answers3

1

The issue is unlikely to be due to the code you've written. It is likely related to how you're saving your .py file, and how it is being ran.

Are you running the file using the 'play' button / Ctrl+F5 in VSCode, or are you double clicking on the .py file from File Explorer / Finder?

If it's the latter, then perhaps you're not saving the file in VSCode first, try saving the file with Ctrl+S first.

Screenshots would likely go a long way to helping you answer this question.

farAndAway
  • 33
  • 6
1

enter image description here

The white dot indicates the file has not been saved.

You can add this in the settings.json file:

  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000,

to enable the autosave function in the VSCode.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
0

Command n (New file..), convert language mode to python from plain text and paste the new block and run ?

Jatin Morar
  • 164
  • 1
  • 7