I'm pretty new to programming and python.
As far as I know, for the initialization of the set function you use set()
for an empty set, and { ... }
to initialize elements as a set. In an example code, I saw set[X]
. What is the meaning of the square brackets used in set?
This is the example code:
def example_function(x: set[A], y: set[B]) -> set[tuple[A, B]]:
res = set()
for i in x:
for j in y:
res.add((i, j))
return res