<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Le 18/09/11 11:39, Kayode Odeyemi a écrit :
<blockquote
cite="mid:CAPbrmCsoavnWQt0m8q7C1f0c0+JQ8pDoRCqoh7i18PX4BFbnmA@mail.gmail.com"
type="cite"><span>Hi all,<br>
<br>
If I have a list with key/value pair, how do I get the value of
the key?</span><br>
<br>
I'm working with this code snippet:<br>
<br>
>>> items = {'fees':[('status','pending'),
('timeout',60)], 'hostel':[('status',<br>
'pending'), ('timeout','120')]}<br>
>>> print [items[i] for i in items.keys()]<br>
[[('status', 'pending'), ('timeout', '120')], [('status',
'pending'), ('timeout'<br>
, 60)]]<br>
>>><br clear="all">
<br>
-- <br>
Odeyemi 'Kayode O.<br>
<a moz-do-not-send="true" href="http://www.sinati.com"
target="_blank">http://www.sinati.com</a>. t: @charyorde<br>
<br>
</blockquote>
Sorry, for python3.x<br>
<br>
# -*- coding: utf-8 -*-<br>
<br>
d = {'fees':[('status','pending'), ('timeout',60)],
'hostel':[('status',<br>
'pending'), ('timeout','120')]}<br>
<br>
for key, value in d.items():<br>
print("\n {0}".format(key))<br>
for val in value:<br>
print("\t{0}: {1}".format(val[0], val[1]))<br>
<br>
<div class="moz-signature">-- <br>
Vincent V.V.<br>
<a href="https://launchpad.net/oqapy">Oqapy</a> . <a
href="https://launchpad.net/qarte+7">Qarte+7</a> . <a
href="https://launchpad.net/paqager">PaQager</a></div>
</body>
</html>