On 8/19/10, Roelof Wobben <rwob...@hotmail.com> wrote: > > Hello, > > > > I have this exercise: > > > > Now write the function is_odd(n) that returns True when n is odd and False > otherwise. Include doctests for this function as you write it. > Finally, modify it so that it uses a call to is_even to determine if its > argument is an odd integer. > > > > So I thought of this : > > > > def is_even(argument): > remainder= argument%2 > if remainder == 0 : > return True > else : > return False > > > def is_odd(argument): > uitkomst=is_even(argument) > return uitkomst The above line, the return statement, has to be indented; it did not appear to be in your email. Also, maybe you want to return the opposite of is_even in is_odd? Right now it looks like you are going to get something like: is_odd(3): is_even(3)=False, so is_odd(3) will echo that False. Maybe return !uitkomst instead. I could have read it wrong, though.
> > > even=is_odd(1) ; > if even==True : > print "Even getal" > if even==False: > print "Oneven getal" > > > > But now I get this error message : > > > > return uitkomst > > Syntax error : return outside function. > > > > > > In my opinon even calls is_odd , then uitkomst calls is_even which gives a > true or false to uitkomst. So return uitkomst gives the outcome to even. > > But the intepreter thinks otherwise. > > > > I work on a Win7 machine with Python 2.7 > > > > Roelof > > > -- Have a great day, Alex (msg sent from GMail website) mehg...@gmail.com; http://www.facebook.com/mehgcap _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor