Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
There is one python module named Main.py and we can make many files even yesterday, I made a new file(not Main.py) named so.py and it operates well when I press the run button but today I try to execute it like that there is nothing on the result screen.

1 Answer

0 votes
by (107k points)

I think there is some connection issue when you were attempting to run the code this time around. That sometimes appears to me as well, but a refresh or two should work.

You've probably done that already so try copying your code to a different repl and try again.

I think you have also deleted, like an import declaration in main.py which would justify why code isn't showing up. Supposing you're calling code from a separate module or package.

import indeed

import so

so.print_hello()

Or you could also import a specific method into your main.py module using this method

from so import function_name, function2_name, etc...

To make it as clear as possible here is an example code if I had done it.

In so.py

def print_hello():

   print('Hello, World!')

In main.py

import so

so.print_hello()

Output will be:

Hello, World!

If you want to know more about this topic then do check out the python certification course that will help you out in a better way.  

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...