Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 78

Python Exercise Example 78

Python 100 Examples Python 100 Examples

**Problem:** Find the oldest person and output it. Please find out what is wrong with the program.

**Analysis:** None.

Program source code:

Example (Python 2.0+)

#!/usr/bin/python

-- coding: UTF-8 --

if

name

==

'

main

'

:

person

= {

"

li

"

:

18

,

"

wang

"

:

50

,

"

zhang

"

:

20

,

"

sun

"

:

22

}

m

=

'

li

'

for

key

in

person

.

keys

(

)

:

if

person

[

m

]

<

person

[

key

]

:

m

=

key

print

'

%s,%d

'

%

(

m

,

person

[

m

]

)

The output of the above example is:


wang,50

Python 100 Examples Python 100 Examples