From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 17 Mar 2026 09:18:16 +0000 (+0100) Subject: [3.13] Docs: a brief note in the sets tutorial about order (GH-145984) (#146050) X-Git-Tag: v3.13.13~82 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2705364de22f8e85db449b551ab6e0b940c9def4;p=thirdparty%2FPython%2Fcpython.git [3.13] Docs: a brief note in the sets tutorial about order (GH-145984) (#146050) Docs: a brief note in the sets tutorial about order (GH-145984) (cherry picked from commit 4f5e79805ebcaa0d3ba1677694d4120a9e8f4513) Docs: a brief note in the sets tut about order Co-authored-by: Ned Batchelder --- diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 7e02e74177c4..5a239d9e3710 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -454,6 +454,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'}