def function

Completed

Hi, Im following a tutorial on how to define a function on pycharm. 

def my_function(): 

mine is not giving the 4 spaces after I press enter 

 

Kind Regards

Lola 

6 comments
Comment actions Permalink

Hi,

Is it a fresh installation?
Make sure *.py is associated with Python file type https://www.jetbrains.com/help/pycharm/creating-and-registering-file-types.html

0
Comment actions Permalink

Hi,

Thank you for replying. I really appreciate it. I downloaded pycharm ages ago - it says 2020.1 pycharm
I'm not sure what I did but I got it to work. There's a yellow ball on my saved work. Before I was doing it on a file? What's the difference between the two? Thanks again for your help.

Kind regards
Lola

0
Comment actions Permalink

Sorry, what yellow ball do you mean?

0
Comment actions Permalink

It's a blue and yellow plus sign. I can see it's a python file(using pycharm). Am I right in saying you can't run a script on a file but it has to be a python file? Sorry what is the difference between the two?
Thanks so much

0
Comment actions Permalink

Do you mean you were writing your code in a plain text file?

If so, then it's expected that there was no auto-indent. You can run a code placed inside *.txt file, but PyCharm won't provide you with code completion, inspections, and so on. So it doesn't make sense to write it in a text file.

0
Comment actions Permalink

Yeah I did. I didn't realise I had to open a python file.
Thank you for explaining that. I've been breaking my head for two days lol
Kind regards

0

Please sign in to leave a comment.