I am trying to create a basic function in Python. Below you can see my code:
# Create function
def return_value_fun(type_1,type_2):
if type_1 < 0:
return 0
else:
return type_1-type_2
# Testing function
return_value_fun(100,100)
This function working well. Now I want to put an additional argument tb
into the function you can see below:
# Create function
def return_value_fun(type_1,type_2,tb):
if type_1 < 0:
return tb = 0
else:
return tb = type_1-type_2
# Testing function
return_value_fun(100,100)
Additional arguments make this function to not work. So can anybody help me how to solve this?
CodePudding user response:
I'm unclear as to what you're trying to do, but if you want to store the returned value inside a variable, it can be done like this:
# Create function
def return_value_fun(type_1,type_2,tb):
if type_1 < 0:
return 0
else:
return type_1-type_2
# Testing function
tb = return_value_fun(100,100)
CodePudding user response:
Answer is :
# Create function
def return_value_fun(type_1,type_2):
if type_1 < 0:
tb = 0
else:
tb=type_1-type_2
return tb