Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98472

Visual Studio Code keeps giving me indent or syntax errors when executing if statements?

$
0
0
loc = 'Bank'

if loc == 'Auto Shop':
    print("Cars are cool!")
elif loc == 'Bank':
    print('Money is cool!')
elif loc == 'Store':
    print('Welcome to the store!')
else:
    print("I do not know much.")

I'm trying to revise some beginner level Python and have been using Visual Studio Code (on Mac) for my scripts. Whenever I try to run blocks of code such as the if statement above, I get error codes like "SyntaxError: invalid syntax" and "IndentationError: unexpected indent". Tried doing my indentation over again and checked my indentation in Sublime and it was fine. The code also runs in my terminal.

I think something is up with my VSC, it's running Python 3.8 which is what I used in my Mac terminal to run the code just fine, but is acting funky when using its terminal.

This is bothering me as it means I might need to switch editors for when I do more complicated stuff later.

Any help would be well appreciated.


Viewing all articles
Browse latest Browse all 98472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>