[Tutor] Calling a dictionary entry inside of a function
Benno Lang
transmogribenno at gmail.com
Sat Sep 19 02:57:25 CEST 2009
On Sat, Sep 19, 2009 at 9:27 AM, Corey Richardson <kb1pkl at aim.com> wrote:
> I am trying to use a parameter of a function to call a word inside a
> dictionary.
> Here is my code
> wordList = {
> 'Apple' : ["A delicious snack"],
> 'Word' : ["This code is not working..."],
> }
> def define(word):
> print wordList['Word']
>
>
> When I use define('Apple') it returns ['This code is not working...'].
That's what you asked it to do, but I think you meant print
wordList[word] instead
HTH,
benno
More information about the Tutor
mailing list