Nitesh Kumar M
Nitesh Kumar M

Reputation: 11

Set intersection not finding common element

I have two sets:

set1 =  {'MIX', 'КANYA', 'МASTER', 'ЕР#19', 'ВНООМІ'}
set2 =  {'RUNNING', 'TIMINGS', 'TIME:', 'ISCI', '0:60', 'AUDIO', 'PRESHOW', 'AUDIO:', 
         'INFO:', 'AGENCY:', 'STEREO', 'TC:', 'FORMAT', '0:30', 'TTT', 'MUSIC:', 'TRT:', 
         'CODE:', 'EP:', 'MASTER', 'EPISODE', ':60', 'EP', 'OUTPUT', 'DATE:', 'CAPTIONED', 
         '00:00:30:00', 'ISCII', 'STEREO:', 'BREAK', 'TITLE:', 'PROGRAM:', 'DURATION', 
         ':30', 'PRODUCTION:', 'SEASON', '00:00:15:00', ':15', 'FPS', 'AIRDATE:', 'TRT', 
         'CLIENT:', 'ISCII:', 'LENGTH:'}

When I try to find set1.intersection(set2) I get empty set though there is a common string "MASTER".

Can anyone let me why this is failing?

Upvotes: 1

Views: 57

Answers (1)

plum 0
plum 0

Reputation: 721

The issue you are experiencing is because your two 'MASTER' elements are not the same. The codepoint for the M in set1 is 1052, whereas the codepoint for the M in set2 is 77.

You can test this by running the following commands in python (I copy and pasted the 'M' character from your two sets above)

# Set 1 M from 'MASTER'
ord('М')

# Set 2 M from 'MASTER'
ord('M')

Upvotes: 2

Related Questions