[Tutor] help

Steven D'Aprano steve at pearwood.info
Thu Jan 9 12:17:57 CET 2014


On Thu, Jan 09, 2014 at 09:52:04AM +0100, Tihomir Zjajic wrote:
> Please, can you help me convert this code from python 3 to python 2.6

Change input() to raw_input(). That will make it compatible with Python 
2.6. But that is not the cause of the error you get. The error that you 
get is that your functions don't always return a value.

For example, if you call prs_prec(), and enter 20, 40 or 80, it will 
return strings "20", "40" or "80". But if you enter 21, it returns 
nothing, or as Python does it, the special value None. Then, later in 
your program, you try to add None, and that doesn't work.

So look at your functions, and think about what they return.


-- 
Steven


More information about the Tutor mailing list