I’m trying to check if each number in a list is evenly divisible by 25 using Python. I’m not sure what is the right process. I want to do something like this:
n = [100, 101, 102, 125, 355, 275, 435, 134, 78, 550]
for row in rows:
if n / 25 == an evenly divisble number:
row.STATUS = "Major"
else:
row.STATUS = "Minor"
Any suggestions are welcome.
Use the modulo operator:
or
n % 25means “Give me the remainder whennis divided by25“.Since
0isFalsey, you don’t need to explicitly compare to0, just use it directly in theif— if the remainder is0, then it’s a major row. If it’s not, it’s a minor row.