From 291430821487e7f3512c1ba769e5044b651f8fc3 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 8 Aug 2010 01:32:06 +0000 Subject: [PATCH] Issue #4570: Clean-up tutorial example --- Doc/tutorial/datastructures.rst | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index 32e4a73361..8394c1086b 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -377,16 +377,12 @@ empty dictionary, a data structure that we discuss in the next section. Here is a brief demonstration:: - >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana'] - >>> fruit = set(basket) # create a set without duplicates - >>> fruit - {'orange', 'pear', 'apple', 'banana'} - >>> fruit = {'orange', 'apple'} # {} syntax is equivalent to [] for lists - >>> fruit - {'orange', 'apple'} - >>> 'orange' in fruit # fast membership testing + >>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'} + >>> print(basket) # show that duplicates have been removed + {'orange', 'bananna', 'pear', 'apple'} + >>> 'orange' in basket # fast membership testing True - >>> 'crabgrass' in fruit + >>> 'crabgrass' in basket False >>> # Demonstrate set operations on unique letters from two words -- 2.40.0