(Nov-22-2020, 10:16 AM)squall Wrote: Anyway I have a question about that:for i in list(a): if i == c: a.remove(i)What does that list(a) there mean? It doesn't work for me.
It creates a new (different) list from some other object.
l = [1, 2, 3] # a list a = l # a is the *same* list b = list(l) # b is a *different* list l.remove(1) # removes the "1" from l (and from a since it's the same list) print(l) print(a) print(b)
Output:[2, 3]
[2, 3]
[1, 2, 3]
It probably doesn't work for you because you've named your function "list", so you've overriden the internal python "list" function.