In Pyton 2.4.2, set1=set(['abracadabra']) results in 'abracadabra' as a member, while set2=set('abracadabra') results in 'a' 'r' 'b' 'c' as members. How do I get the input from a raw_input query into a set1 type set? How should the input be made?
A string is a special case of a sequence. Since set expects a sequence as its argument, it splits it into component elements. The first example you gave, since the argument is a sequence containing a sequence is the correct way to accomplish what you want.
As a side note, if you'd tried you second example passing in a number instead of a string (which is a sequence) you would have gotten an exception indicating that a sequence is required.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.