scapegoat17
scapegoat17

Reputation: 5821

Trying to run my python script doesnt do anything

Sorry for the vague title, but I am unsure how else to explain it. Running the command in terminal:

python --version

Outputs:

Python 3.9.10

When I try to run my main.py file using the command: python main.py or python3 main.py nothing outputs. I am new to Python and this was just working but I restarted my computer and now I cant get any of my Python scripts to output or run.

This is all that my main.py is:

def main():
    print("hello world")

Does anyone have any ideas?

Upvotes: 1

Views: 400

Answers (2)

ce7in
ce7in

Reputation: 31

You need to call the method. Just defining a method is not enough to run it.

Try this:

def main():
    print("hello world")

main()

Upvotes: 1

Rohith Nambiar
Rohith Nambiar

Reputation: 3730

You have to call the function:

def main():
    print("hello world")

main()

Upvotes: 3

Related Questions