I am new to python and trying to use tuple with sets through comprehension

U={'u1','u2','u3','u4'}

R={'r1','r2','r3','r4'}

UR=(('u1','r1'),('u1','r2'),('u2','r3'),('u3','r3'),('u4','r3'),('u4','r4'))

- Code: Select all
`def assignedRoles(u):`

for i in U:

for x,y in u:

if i==x:

print (x,y)

this gives me user with roles correctly but then i tried to do the same through comprehension like

- Code: Select all
`def assignedRoles(u):`

m={y for x,y in u if x=={k for k in U}}

print (m)

Is my use of comprehension wrong since i am getting empty set as output?

I am calling the function as:

assignedRoles(UR)

Please help!!!!

Thanks

Abhinav