Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python string in set

a_string = 'Hello World Hello'

# In case we want to get a 'set' of chars
print(set(a_string))
# Output -> {'W', 'r', 'l', 'H', 'd', ' ', 'o', 'e'}

# In case we want to get a 'set' of words
print(set(a_string.split()))
# Output -> {'Hello', 'World'}
 
PREVIOUS NEXT
Tagged: #python #string #set
ADD COMMENT
Topic
Name
8+9 =