19 December 2017

unpacking argument in python

# how to unpack argument in a functiondef health_calculator(age,apple_amnt, num_ciggrt):
    #this equation is just for consideration    health = (100-age) + (apple_amnt*3.5) - (num_ciggrt*2.5)
    print(health)

dieat_list = [45,10,1]
health_calculator(dieat_list[0],dieat_list[1],dieat_list[2])
health_calculator(*dieat_list)

No comments:

Post a Comment

UVA 10679 - I Love Strings!!