i have written this program but i have gott following error,
in anather proram "indentation error" sir how i will indent in my
editor

#test.py
>>> def invert(table):
        index=()
        for key in table:
                value=table[key]
                if not index.has_key(value):
                        index[value]=[]
                        index[value].append(key)
                return index


>>> phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu': 9325}
>>> phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
>>> print phonebook
{'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
>>> inverted_phonebook = invert(phonebook)

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    inverted_phonebook = invert(phonebook)
  File "<pyshell#9>", line 5, in invert
    if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'
>>> interted_phonebook= invert(phonebook)

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    interted_phonebook= invert(phonebook)
  File "<pyshell#9>", line 5, in invert
    if not index.has_key(value):
AttributeError: 'tuple' object has no attribute 'has_key'
>>>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to