Hi All
I am trying to learn Python and cannot get aroud this problem for the life of me.
I have generated a sript as follows, called xandy.py
def xandy (x,y):
if x < y:
print x, "is less than", y
elif x > y:
print x, "is greater than", y
else:
print x, "and", y, "are equal"
I cannot get it to work in the shell?
>>> x=5
>>> y=4
>>> xandy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'xandy' is not defined
>>> xandy (5,4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'xandy' is not defined
>>>
Thanks in anticipation
chico2009
0
Newbie Poster
Recommended Answers
Jump to Post2 ways at least: you can type
>>> from xandy import xandy
and then use your function. The file must be in a place where python will find it (in a folder listed in your PYTHONPATH environment variable.
Second (and best) way, run python's built-in gui IDLE …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.