S={1,2,3} R={(1,2),(2,1),(3,3),(1,1),(2,2)} def equivClass(S,R): return {frozenset({y for y in S if(x,y) in R}) for x in S}
equivClass(S,R) Traceback (most recent call last): File "<pyshell#6>", line 1, in equivClass(S,R) NameError: name 'S' is not defined