Description
Bug report
Bug description:
# Add a code block here, if required
for n in range(2,10):
for x in range(2,n):
if n %x == 0:
print(n,'equals',x,'*',n/x)
break
else:
print(n,'is prime')
The following is output on Windows 11 with either py or as a def
3 is prime
4 equals 2 * 2
5 is prime
5 is prime
5 is prime
6 equals 2 * 3
7 is prime
7 is prime
7 is prime
7 is prime
7 is prime
8 equals 2 * 4
9 is prime
9 equals 3 * 3
Tried the following
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
if x == (n - 1):
print(n, 'is a prime number')
The output
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Activity
unixio commentedon May 15, 2025
Experienced programmer. Learning python. Test examples to learn
hugovk commentedon May 15, 2025
Please don't open spam issues.
[-]Section 4.4 tutorial[/-][+]spam[/+]unixio commentedon May 15, 2025
[-]spam[/-][+]Section 4.4 tutorial[/+]hugovk commentedon May 15, 2025
You opened a bug report and then closed it.
Sorry, I didn't look closely at the report the first time, but this issue tracker is for bug reports in the Python programming language itself.
The code in section 4.4 of the tutorial works as advertised. Please could you open a topic in the help forum if you'd like assistance with your modified code?
https://discuss.python.org/c/help/7
Thank you.