[Tutor] Return problems
Steven D'Aprano
steve at pearwood.info
Sat Apr 7 04:36:50 EDT 2018
On Fri, Apr 06, 2018 at 05:50:35PM -0700, Roger Lea Scherer wrote:
> So I've examined my educational material, I've perused the python
> documentation and for the life of me I can't figure out why return doesn't
> print a result in the IDE. I use print, the program acts as expected. What
> am I missing?
What IDE are you using?
In the standard Python interactive interpreter, calling findHypot(3, 4)
ought to print 5. The same applies in IDLE, or iPython. That's a
convenience feature for interactive use.
But if you use IDLE to run the file as a script, using the Run Module
command, then you're running in "batch mode", so to speak, and results
aren't printed unless you explicitly use the print command.
So try changing your script to:
print(findHypot(3, 4))
for Python 3, or
print findHypot(3, 4)
for Python 2.
--
Steve
More information about the Tutor
mailing list