and wonders why it doesn't work (it prints the value but returns
Try this instead:
This probably belongs in the FAQ: any expression that doesn't evaluate
to "None" is printed when executed as a statement. This is useful
when using Python as an interactive calculator. I left it in for
non-interactive statements: partly to simplify the interpreter (it's
not always easy to figure out whether a statement is executed
interactively; partly for consistency (a statement's effect is the
same interactively or in a function); partly to force programmers to
think about what to do with function return values. If you don't want
to use a value returned by a function you have to assign it to a dummy
variable. If you want to return it, you must use a return statement.
--Guido van Rossum, CWI, Amsterdam <email@example.com>
"I don't care how excrementally runny it is, hand it over with all speed!"