Dec-05-2019, 04:53 AM
Lists don't store values; they store references to memory locations. Anything that returns an object (and everything in Python is an object) has a memory location. So, each index in a list can be conceptualized as a variable storing a reference to some object. Leveraging that, we can do things like the code above to store anonymous objects.
The same holds true for tuples, sets, and dicts as well, but they aren't necessarily as useful in this case as a list.
The same holds true for tuples, sets, and dicts as well, but they aren't necessarily as useful in this case as a list.