Using Python to keep track of deaths (Twitch bot) -
i working on command twitch bot keep track of deaths streamer experiences while playing game. trying have can !adddeath
, death added counter. how tried it, , it's wrong because doesn't keep track of deaths spits out 0 + 1 is. need way '1' added death
value everytime !adddeath
executed.
def command_adddeath(): death = 0 death2 = 1 sum = float(death) + float(death2) print('the sum of {0} , {1} {2}'.format(death, death2, sum)) send_message(chan, 'death counter has been updated!')
thank ahead of time!
you can define variable, called counter. then, add 1 counter every time function run:
counter = 0
then, make function, , make sure bring variable scope using global keyword:
def command_adddeath(): global counter counter += 1 print(counter) send_message(chan, 'death counter has been updated!')
the reason function doesn't work setting variables every time run it. however, if have accumulator, or counter, solve problem.
Comments
Post a Comment