Feb-16-2023, 09:20 AM
(Feb-15-2023, 07:21 PM)buran Wrote:(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)and
Output:[1, 2, 3]
spam = [1, 2, 2, 3] for item in spam[::]: if item == 2: spam.remove(item) print(spam)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.
Output:[1, 3]
Also, note that I uselist.remove
, notdel 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
Thanks again for the assistance. I think I fixed my habit and main.py files. I don't know where to begin on the db.py file since those errors escape me. Are we talking about indentation, the SQL, variables? I wrote a tester.db file that works just fine using the same logic, but in my original db.py file when I put the same logic behind classes and functions, it all goes out the window.