0
while loop in Python
The below shows a program to print all the prime numbers between an interval. https://code.sololearn.com/ccZc3UjQCPZu I am not understanding how it is able to judge 2 is a prime number as at the starting 2%2=0 and the inner for loop should be exited.
1 Odpowiedź
+ 2
When num = 2 we have
for i in range(2, 2):
Which is an empty range so it's skipped, then the else part is executed and the number is printed.