I have a string
sample = "http://www.stackoverflow.com"
I want convert this string to a set
final = {"http://www.stackoverflow.com"}
I tried the following code:
final = set(sample)
But i got the wrong out as
{u'.', u'/', u':', u'a', u'b', u'c', u'e', u'h', u'i', u'k', u'l', u'n', u'p', u's', u't', u'w'}
I also used
final = ast.literal_eval(Sample)
and I got this
SyntaxError: invalid syntax
Is there any other solution for this
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