I have just started learning python version 3 and trying to create a file in python.
I placed the file in all the places which is shown by this set of command.
import sys
sys.path
The file has a simple function something like this
def hello(var):
print("Hello "+var)
But when I run it
hello("Google")
I am getting NameError.
Please can anybody help me? I am using Windows. Or is it that I have to call by file name and not by function name? If so, how should I call it?
Thanks in advance to whoever helps me.
You need to
importyour file first:(assuming your file is called
myModule.py)Then you can call the function like this:
Alternative syntax: