C. · @cazabon
142 followers · 2876 posts · Server mindly.social

@foo

It's a little what's going on here if you put it this way:

>>> b = []
>>> b.append(b)
>>> b
[[...]]
>>> b is b[0]
True

So all you've done is create a , and then (not extend) that list to itself. Since `a` and `a[0]` are the same , the `in` test will return True either way.

#clearer #list #append #object

Last updated 1 year ago