In the tutorial there is an example for finding prime numbers:
>>> for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print(n, 'equals', x, '*', n//x) ... break ... else: ... # loop fell through without finding a factor ... print(n, 'is a prime number') ...
I understand that the double
== is a test for equality, but I don't understand the
if n % x part. Like I can verbally walk through each part and say what the statement does for the example. But I don't understand how the percentage sign falls in.
if n % x actually say?