We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It is used for unpacking the list. As per syntax, set.intersection() takes multiple sets as input and gives intersection of all of them as result.
The line gems = set.intersection(*rocks) is equivalent to writing :
gems = set.intersection(rocks[0],rocks[1],...,rocks[N-1]) with "..." replaced by proper values. But, since number of rocks is arbitrary it can't be coded this way.
Thus, * operators makes implementation a lot convenient here. Still, there can be several alternate ways. Statement gems = set.intersection(*rocks) can be replaced by following code :
Gemstones
You are viewing a single comment's thread. Return to all comments →
It is used for unpacking the list. As per syntax,
set.intersection()
takes multiple sets as input and gives intersection of all of them as result.The line
gems = set.intersection(*rocks)
is equivalent to writing :gems = set.intersection(rocks[0],rocks[1],...,rocks[N-1])
with "..." replaced by proper values. But, since number of rocks is arbitrary it can't be coded this way.Thus, * operators makes implementation a lot convenient here. Still, there can be several alternate ways. Statement
gems = set.intersection(*rocks)
can be replaced by following code :