summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-08-08 01:30:45 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-08-08 01:30:45 (GMT)
commitafdeca980de5bf1385bce1e7d56a56d75b7b5734 (patch)
treed3ffeb770d099408f8f551ebcbc8b00474aab013 /Doc
parentd331ce9e6686f180373853fef5d819f36d331d44 (diff)
downloadcpython-afdeca980de5bf1385bce1e7d56a56d75b7b5734.zip
cpython-afdeca980de5bf1385bce1e7d56a56d75b7b5734.tar.gz
cpython-afdeca980de5bf1385bce1e7d56a56d75b7b5734.tar.bz2
Issue #4570: Clean-up tutorial example
Diffstat (limited to 'Doc')
-rw-r--r--Doc/tutorial/datastructures.rst14
1 files changed, 5 insertions, 9 deletions
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index 32e4a73..8394c10 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