From 4601007395133d615a56aa08b0cadf673e018360 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 17 Mar 2026 10:18:11 +0100 Subject: [PATCH] [3.14] Docs: a brief note in the sets tutorial about order (GH-145984) (#146049) 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 --- Doc/tutorial/datastructures.rst | 3 +++ 1 file changed, 3 insertions(+) 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'} -- 2.47.3