I’m having trouble with a personal project. There is a particular part of code, where sometimes it will act as if the if condition is false when it’s true and I can’t figure out why. This is for the elif at the bottom. Below are my error, prints, and code fragment. The issue only seems to appear when there is only one object in the list and even then only sometimes.
The code. The elif is what I’m having the issue with.
The error. The “Aa” coresponds to print(self.stars[i].starName), the “1” corresponds to print(len(self.stars)), the “True” corresponds .print(“b” not in self.stars[i].starName), and the “[]2” corresponds with a print elsewhere that prints out the new list later on
I tried printing out the relevant attributes to see if I was missing something. I was expecting to see a flaw that I wouldn’t have caught be code tracing but all the prints imply that the elif should work.
NDiaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1