new_set = set('Hello')
I want just {'Hello'} instead of each individual character as a part of the set
Use a set literal:
new_set = {'hello'}
The set constructor expects an iterable, and it'll add each item of the iterable to the set. Strings are iterable. Hence, each letter of the string is added to the set.
That being said, do this instead:
new_set = set(['Hello'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With