I am new to python and just in the initial phase of the basics. Can someone please explain me how the for loop in the below code works? and I really don't get how number 9 is getting 3 as inner value.
Kindly tell me how the loops executes. TIA.
CODE:
for outer in range(2,10):
for inner in range(2,outer):
if not outer%inner:
print(outer,'=',inner,'*',int(outer/inner))
break
else:
print(outer,'is prime')
Output:
2 is prime
3 is prime
4 = 2 * 2
5 is prime
6 = 2 * 3
7 is prime
8 = 2 * 4
9 = 3 * 3