How Can I Use Remove For This Code?
class student(object): def student(self): self.name=input('enter name:') self.stno=int(input('enter stno:')) self.score=int(input('enter score:'))
Solution 1:
just call
y.remove(c)
when you do c.stno
it won't exist in the list because what is actually in the list is the object itself not it's attributes
Solution 2:
It's not good to change the array you are iterating. You can try this:
for item in [c for c in y if s.stdno==n]:
y.remove(item)
Post a Comment for "How Can I Use Remove For This Code?"