The variable last_days
is local within the count_days
function. That means that as soon as the function ends, the variable is no longer available. That is however not a problem as the function actually returns that value, making it available for others.
So when you do my_var = count_days(amount, dose)
, then the function will execute, and return its last_days
result which is then stored in my_var
.
last_days = count_days(amount, dose)
print("Your medicine will run out in ", last_days, " days.")