Posted by : ANIL KUMAR MULA Friday, 2 January 2015




#passing function to a function

def do(x,y):
    # this function is to check if first argument is greater than second
 
    if x > y:
     
        return [True,x,y]
    else:
        return [False]

def sub(func):
    lis = func
    #lis = [False]
    #lis = [True,3,2]
    if lis[0] == True:
        return lis[1] - lis[2]
    else:
        return "sub not possible"



print((sub(do(2,3))))  # none
print((sub(do(3,2))))  # 1

{ 3 comments... read them below or Comment }

  1. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Python Training in Bangalore

    ReplyDelete
  2. Casino Secret 100% Free Spins + No Deposit Bonus Code
    Casino Secret 인카지노 100% Free カジノ シークレット Spins + No Deposit Bonus Code The secret 100% free casino bonus code is 100% match up to matchpoint a new player on the first deposit.

    ReplyDelete

- Copyright © Anil Kumar Mula - Skyblue - Powered by Blogger - Designed by Johanes Djogan -