mercredi 19 février 2020

How to get a total number of occurrences in an IF statement

After looking at a bunch of the other questions similar to mine, I found one that partially works but not exactly as I need it to. I am trying to get a total for the number of times an occurrence is found in my IF statement. The code I have tried is below:

Total = 0
if data['red'] and data['blue'] > 0:
    Total += 1
    print('Total:', Total)

Rather than giving me an output like:

Total: 3

I get this:

Total: 1
Total: 1
Total: 1

Aucun commentaire:

Enregistrer un commentaire