Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit afdeca9

Browse files
committed
Issue #4570: Clean-up tutorial example
1 parent d331ce9 commit afdeca9

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

Doc/tutorial/datastructures.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,12 @@ empty dictionary, a data structure that we discuss in the next section.
377377

378378
Here is a brief demonstration::
379379

380-
>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
381-
>>> fruit = set(basket) # create a set without duplicates
382-
>>> fruit
383-
{'orange', 'pear', 'apple', 'banana'}
384-
>>> fruit = {'orange', 'apple'} # {} syntax is equivalent to [] for lists
385-
>>> fruit
386-
{'orange', 'apple'}
387-
>>> 'orange' in fruit # fast membership testing
380+
>>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
381+
>>> print(basket) # show that duplicates have been removed
382+
{'orange', 'bananna', 'pear', 'apple'}
383+
>>> 'orange' in basket # fast membership testing
388384
True
389-
>>> 'crabgrass' in fruit
385+
>>> 'crabgrass' in basket
390386
False
391387

392388
>>> # Demonstrate set operations on unique letters from two words

0 commit comments

Comments
 (0)