def function

已完成

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 

0

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

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

Sorry, what yellow ball do you mean?

0

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

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

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

I finally figured it out.

0

请先登录再写评论。