https://github.com/python/cpython/commit/4601007395133d615a56aa08b0cadf673e018360 commit: 4601007395133d615a56aa08b0cadf673e018360 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: nedbat <[email protected]> date: 2026-03-17T05:18:11-04:00 summary:
[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 <[email protected]> files: M Doc/tutorial/datastructures.rst diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 7e02e74177c457..5a239d9e371000 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'} _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
