I am getting some failures with Python sets.
a={1,2,3} gets an error, but
a=set((1,1,1,2)) gets no error.
print(a) then gives a lot of code, but
print([a]) gives [{1, 2}]
a=set(1,2)
print([a]) gives [{}] I can live with that.
if 1 in a: print(1) gives 1. Good.
But I don't find any way to put tuples into a set.
a=set([1,2], [1,3], [1,1])
print([a]) gives [{1, 2}] as if it processes the first item.
a=set(([1,2], [1,3], [1,1]))
print([a]) gives [{[1, 2], [1, 3], [1, 1]}] as if it keeps the whole thing as one set element. But I can't find a way to get it to say that item is in the set. I haven't found any combination of writing them as tuples (instead of the lists as above) that works.
a=set((1,2,3))
b=set((4,5,6))
c=a.union(b)
print([c]) gives [{1, 2, 3, 4, 5, 6}] Good.
Do tuples just not work? Or is there a workable syntax I didn't find?
--
Jonah Thomas
We are limited, but the limits aren't where we think they are. We find them only by exceeding them.