set intersection : Set « Data Structure « Python
- Python
- Data Structure
- Set
set intersection

import sets
magic_chars = sets.Set('abracadabra')
poppins_chars = sets.Set('supercalifragilisticexpialidocious')
print ''.join(magic_chars & poppins_chars)
Related examples in the same category