Usage instances of sets modules in python
- 2020-04-02 14:12:41
- OfStack
This article is a simple example of how to use the sets modules in python.
Specific methods are as follows:
import sets
magic_chars = sets.Set('abracadabra')
print magic_chars
poping_chars = sets.Set('supercalifragilisticeexpialidocious')
print poping_chars
print "".join(magic_chars & poping_chars)
The results of the program are as follows:
Set(['a', 'r', 'b', 'c', 'd'])
Set(['a', 'c', 'e', 'd', 'g', 'f', 'i', 'l', 'o', 'p', 's', 'r', 'u', 't', 'x'])
acrd
I hope this article has helped you with your Python programming.