vendredi 27 mars 2020

Can you explain the use of modulo operator in an if statement

m = 1
my_list_1 = [2 , 4, 1]
for x in my_list_1:
    for y in range(1,3):
        if (x + y) % 3:
            m = m * x
print (m)

In line 5, what does the modulo operator do. Doesn't is need something like == 1?

Aucun commentaire:

Enregistrer un commentaire