Alan Cameron wrote: > I am not sure of this is the right place to ask a question about the > tutorial > > http://docs.python.org/3.0/tutorial/datastructures.html#sets > > why is the printed result of > >>>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'} >>>> print(basket) > {'orange', 'banana', 'pear', 'apple'} > > in the sequence given?
As already said by others, the order of items in a set is not part of the concept of a set. You can even have sets with equal contents that display differently: Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = {'orange', 'banana', 'apple', 'orange', 'pear', 'apple'} >>> b = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'} >>> a == b True >>> repr(a) == repr(b) False >>> a {'orange', 'pear', 'apple', 'banana'} >>> b {'orange', 'pear', 'banana', 'apple'} Peter -- http://mail.python.org/mailman/listinfo/python-list