So basically, I don't really get how this simple code makes sense. The purpose is to identify the duplicates in a list and remove them. The code is:
number = [1,2,3,4,5,5,6,6,7,8,9] newnum = [] for num in number: if num not in newnum: newnum.append(num) print(newnum) Specifically in the if num not in newnum, why does it need to compare to an empty list instead of the original list? How does that work and how does it know that the numbers in the number list is not in the newnum list? When I first thought of a way of solving this problem, it was pretty much the same but I would've put a != operator on it but (Hopefully that's possible too) I gave up. If anyone's willing to try explaining this simple question thank you very much!
!=would be plain wrong (as a number never compares to a list).