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'}
Here is what the above code is Doing:
1. We have a string ‘a_string’
2. We convert it to a set using the set() function
3. We print the set