From: Ned Batchelder Date: Tue, 17 Mar 2026 09:03:11 +0000 (-0400) Subject: Docs: a brief note in the sets tutorial about order (#145984) X-Git-Tag: v3.15.0a8~279 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f5e79805ebcaa0d3ba1677694d4120a9e8f4513;p=thirdparty%2FPython%2Fcpython.git Docs: a brief note in the sets tutorial about order (#145984) Docs: a brief note in the sets tut about order --- diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index eba2474cd400..d3541c604683 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -493,6 +493,9 @@ Curly braces or the :func:`set` function can be used to create sets. Note: to create an empty set you have to use ``set()``, not ``{}``; the latter creates an empty dictionary, a data structure that we discuss in the next section. +Because sets are unordered, iterating over them or printing them can +produce the elements in a different order than you expect. + Here is a brief demonstration:: >>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}