and I'm trying to figure out how I would go about passing local variables to a function and then returning the modified values. I've written the code below:
def main():
change = 150
coins = 0
quarter = 25
while (change >= quarter):
change = change - quarter
coins += 1
print(coins)
if __name__ == "__main__":
main()
But I'd like to be able to extract the modification of the change and coins variables like so:
def main():
change = 150
coins = 0
quarter = 25
while (change >= quarter):
count (change, coins, quarter)
def count(change, count, n):
change = change - n
count += 1
return change, count
if __name__ == "__main__":
main()
However, I know this isn't the way to do it. From what I understand, there could be an issue with trying to return multiple variables from the function, but it also seems like there an issue when I try to even modify only the change variable within the count function. I would really appreciate any advice.