[Tutor] flow problem with a exercise

Alan Gauld alan.gauld at btinternet.com
Fri Aug 20 10:16:57 CEST 2010


"Roelof Wobben" <rwobben at hotmail.com> wrote 

Others have pointed out the lack of indentation.
I'll point out some shortcuts you can use...

def is_even(argument):
    remainder= argument%2
    if remainder == 0 :
        return True
    else :
        return False

You can abbreviate this to just

def is_even(arg):
    return not arg%2

def is_odd(argument):
  uitkomst=is_even(argument)
return uitkomst

and this to:

def is_odd(arg):
   return not is_even(arg)

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list