On Fri, 13 Jul 2007 20:44:13 +0300, <[EMAIL PROTECTED]> wrote:

>
> Hi!
> My code is
>
>  > db = {}
>  >
>> def display():
>>     keyList = db.keys()
>>     sortedList = keyList.sort()
>>     for name in sortedList:
>>         line = 'Name: %s, Number: %s' % (name, db[name])
>>         print line.replace('\r', '')
>
> And it gives following error:
>
>>     for name in sortedList:
>> TypeError: 'NoneType' object is not iterable
>
> How can sortedList variable turn into NoneType? I just don't get it...

db is out of scope, you have to pass it to the function:
>> def display(db):
>>     keyList = db.keys()
>>     sortedList = keyList.sort()
>>     for name in sortedList:
>>         line = 'Name: %s, Number: %s' % (name, db[name])
>>         print line.replace('\r', '')


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to