Reputation: 1
I am using VS studios, using python. When I try to create a function, I constantly keep getting a syntax error. I am not sure why?
def sayhi():
print("Hello User")
sayhi()
Upvotes: 0
Views: 83
Reputation: 1
do it in jupyter notebook on Visual Studio and you won't have any problems. Just make sure you're on the python interpreter
Upvotes: 0
Reputation: 816
Your function should have correct indentation like so:
def sayhi():
print('Hello User')
sayhi()
Otherwise python will throw a fit as indentation is very important to python and its functions, classes, etc.
The issue in your code is the space before def sayhi():
which is going to throw an IndentationError without a doubt, remove that space and you should be much better off
Upvotes: 1