[Tutor] printing a key not a value

Dipo Elegbede delegbede at dudupay.com
Tue Oct 25 15:59:52 CEST 2011


>>> definitions =
{'name':'dipo','food':'spaghetti','age':30,'location':'lagos'}
>>> definitions.keys()
['food', 'age', 'name', 'location']
>>> definitions.values()
['spaghetti', 30, 'dipo', 'lagos']
>>>


You can do this to get what you want.
Hope it helps.

On Tue, Oct 25, 2011 at 2:54 PM, <bodsda at googlemail.com> wrote:

> Sure,
>
> mydict = {'a':1, 'b',2}
> for key in mydict:
>    print key
>
> Hope this helps,
> Bodsda
> Sent from my BlackBerry® wireless device
>
> -----Original Message-----
> From: ADRIAN KELLY <kellyadrian at hotmail.com>
> Sender: tutor-bounces+bodsda=googlemail.com at python.org
> Date: Tue, 25 Oct 2011 13:45:50
> To: <tutor at python.org>
> Subject: [Tutor] printing a key not a value
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111025/24b9f38e/attachment.html>


More information about the Tutor mailing list