I'm new to Python. My codes are similar to this example:
banana = ps.Series(x)
def chocolate(co):
co=math.sqrt(co)
if co > 10:
milk = co - 5
else:
milk = co + 5
and i want to take the milk value to be calculated again outside the function like this:
chocolate(banana)
banana_milk=banana.pow(milk)
I've tried it and got NameError: name 'milk' is not defined
. How to fix it? should i use class? if i use class, i still don't get where to put the 'milk' definition
Please don't ask me to do all outside the function. My code is more complicated than the example.