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
   

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

 
                                          
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to