vertigo wrote: > I receive such error: > File "p4.py", line 24, in PrintWordCountFloat > print "%s %f" % (word,words[word]) > TypeError: list indices must be integers > > i call PrintWordCountFloat with hash table, keys are words(string) and > values float. > This part of the code: > > def PrintWordCountFloat(words): > number = 0 > for word in words: > print "%s %f" % (word,words[word]) #line 24 > number = number + 1 > print "Total words: %d" %(number) > > My function displays whole table correctly, and after that i receive > mentioned error. > Why ? Where is the problem ?
You could be calling PrintWordCountFloat() twice, once with a dictionary and then with a list :-) If I'm wrong, you have to provide more code. Peter -- http://mail.python.org/mailman/listinfo/python-list