I've seen this type of topic already answered. But none of the answers, I've seen seem to work for me. because I think its related to different version of Python. The tutorial I'm watching uses Python2.x
and the code is working fine in Python 2.x
. But I'm using Python 3.x
and It's not working in Python 3.x
.
I am just trying to call a function in separate file. But when I run the main program file, i.e. mainPrg.py, I'm stuck with this error message.
NameError: name 'printHello' is not defined
Prg1.py
def printHello():
print("Hello Son")
input()
mainPrg.py
import Prg1
printHello()
Is there any problem with my code?