I'm having an issue because i have to run the same function many times and want to record a total for every time it was run.
def add(word):
total_hello=0
total_world=0
if word=="hello":
total_hello+=1
elif word=="world":
total_world+=1
print(total_hello)
print(total_world)
return total_hello, total_world
hello=0
world=0
hello, world+=add("hello")
hello, world+=add("world")
hello, world+=add("hello")
print(hello)
print(world)
Making hello a variable and trying to make it += the return doesn't work. Is there anything simple i can do to add the returns efficiently?