classification
Title: prime numbers loop issue
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: paul.moore, steve.dower, steven.daprano, tim.golden, valeriymartsyshyn, zach.ware
Priority: normal Keywords:

Created on 2020-12-16 10:16 by valeriymartsyshyn, last changed 2020-12-16 10:26 by steven.daprano. This issue is now closed.

Files
File name Uploaded Description Edit
main.py valeriymartsyshyn, 2020-12-16 10:16
Messages (2)
msg383135 - (view) Author: Валерій Марцишин (valeriymartsyshyn) Date: 2020-12-16 10:16
I have written a program which must show prime numbers. At the beginning it does, but from some moment it doesn't work properly, despite the fact that it is a loop. I suspect there is a bug somewhere, if not, I'll be thankful if you tell me the issue.





valera0639@gmail.com
msg383140 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-12-16 10:26
Hello valeriymartsyshyn,

This is for reporting bugs in the Python interpreter, it is not a help desk for learning how to program in Python. There are many places you can ask for help to debug your code, such as Reddit's r/learnpython, or Stackoverflow, or the tutor mailing list:

https://mail.python.org/mailman/listinfo/tutor

There are various Python IRC channels or Discuss, if you google you will soon find them.

In this case, your bug occurs because you are deleting items from the list as you are iterating over it. Don't do that.
History
Date User Action Args
2020-12-16 10:26:17steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg383140

resolution: not a bug
stage: resolved
2020-12-16 10:16:23valeriymartsyshyncreate