(Feb-15-2023, 05:46 PM)BCopeland64 Wrote: Also, can you suggest a better way to iterate over the copy of the list rather than changing it as you mentioned?
Compare
spam = [1, 2, 2, 3] for item in spam: if item == 2: spam.remove(item) print(spam)
Output:[1, 2, 3]
and spam = [1, 2, 2, 3] for item in spam[::]: if item == 2: spam.remove(item) print(spam)
Output:[1, 3]
It may be irrelevant in your case, but it's not clear if you want to allow duplicate names. In mark_complete you break immediatelly when name is found (it implies no duplicate names by design) but in mark_incomplete you iterate over whole list and this imply duplicate names.Also, note that I use
list.remove
, not del list[i]
But my preference will be
spam = [1, 2, 2, 3] spam = [item for item in spam if item != 2] print(spam)Check https://stackoverflow.com/q/1207406/4046632
With regards to DB part - there are plenty of trivial errors in the db.py that do not allow the code to run, I mean not run at all
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs