From 1df87ccee1f9300ccb979e56cde7a88f4f817bd6 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Mar 2026 14:10:24 -0400 Subject: [PATCH] Docs: a brief note in the sets tut about order --- Doc/tutorial/datastructures.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index eba2474cd4009d..d3541c604683e4 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'}