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

Skip to content

Commit e0906d1

Browse files
committed
A few more fixes to the tutorial
1 parent 7aa02e6 commit e0906d1

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

Doc/tutorial/controlflow.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,7 @@ function like this::
436436
print("-- I'm sorry, we're all out of", kind)
437437
for arg in arguments: print arg
438438
print('-'*40)
439-
keys = keywords.keys()
440-
keys.sort()
439+
keys = sorted(keywords.keys())
441440
for kw in keys: print(kw, ':', keywords[kw])
442441

443442
It could be called like this::

Doc/tutorial/datastructures.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ Here is a small example using a dictionary::
400400
>>> tel['irv'] = 4127
401401
>>> tel
402402
{'guido': 4127, 'irv': 4127, 'jack': 4098}
403-
>>> tel.keys()
403+
>>> list(tel.keys())
404404
['guido', 'irv', 'jack']
405-
>>> tel.has_key('guido')
406-
True
407405
>>> 'guido' in tel
408406
True
407+
>>> 'jack' not in tel
408+
False
409409

410410
The :func:`dict` constructor builds dictionaries directly from lists of
411411
key-value pairs stored as tuples. When the pairs form a pattern, list
@@ -435,10 +435,10 @@ Looping Techniques
435435
==================
436436

437437
When looping through dictionaries, the key and corresponding value can be
438-
retrieved at the same time using the :meth:`iteritems` method. ::
438+
retrieved at the same time using the :meth:`items` method. ::
439439

440440
>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
441-
>>> for k, v in knights.iteritems():
441+
>>> for k, v in knights.items():
442442
... print(k, v)
443443
...
444444
gallahad the pure

0 commit comments

Comments
 (0)