I'm looking at the solution for how to create a hash table in python and came across this function:
def __init__(self, size):
self.size = size
self.table = [[] for _ in range(self.size)]
The third line of code creating the multi-dimensional array is confusing me. Mainly this part:
for _ in range(self.size)
What exactly is this doing? And why is it needed instead of just doing something like this:
[[] self.size]
Which would create a 2-dimensional array with the size of self.size correct? Any sort of visual aids would really help too.