In the figure to the left of the code is I played, the bottom right hand corner of the figure code is a reference code, how can I feel no problem,
But I run the code has been an error TypeError: 'builtin_function_or_method object is not subscriptable
Have big help me look at it, thank you very much ~
CodePudding user response:
Looked at it and probably should be
Word, count=counts. The items [I]
You missed your dictionary variable
CodePudding user response:
Said the,
In your code,
Word, count=wordCounts. Items [I]
Instead of
Word, count=items [I]
CodePudding user response:
refer to the second floor old coconut response: spoke against, In your code, Word, count=wordCounts. Items [I] Instead of Word, count=items [I] But I changed my added IndexError: list index out of range, good meng CodePudding user response:
This is you don't have according to the number of elements in the items in the traversal, lead to list indices beyond the border, the for I in range (10), instead of for I in range (len (items), CodePudding user response:
Hajo_ reference 4 floor response: this is you don't have according to the number of elements in the items in the traversal, lead to list indices beyond the border, the for I in range (10), instead of for I in range (len (items), I don't have to such an error output, as if my dictionary no deposit, my dictionary operation there is a problem, statistics is a chapter of the English original, so dictionary items that should be more than 10, but the dictionary I look like and or normal operation CodePudding user response:
You this sentence for the line in f1 is wrong, not f1 is above the line CodePudding user response:
refer to fifth floor qing right right reply: Quote: refer to 4th floor Hajo_ response: This is you don't have according to the number of elements in the items in the traversal, lead to list indices beyond the border, the for I in range (10), instead of for I in range (len (items), I don't have to such an error output, as if my dictionary no deposit, my dictionary operation there is a problem, statistics is a chapter of the English original, so dictionary items that should be more than 10, but the dictionary I look like and or normal operation And your function processLine () is no parameters, why you incoming parameters, will not be an error, this is very strange? CodePudding user response:
refer to 7th floor Hajo_ response: Quote: refer to fifth floor qing right right reply: Quote: refer to 4th floor Hajo_ response: This is you don't have according to the number of elements in the items in the traversal, lead to list indices beyond the border, the for I in range (10), instead of for I in range (len (items), I don't have to such an error output, as if my dictionary no deposit, my dictionary operation there is a problem, statistics is a chapter of the English original, so dictionary items that should be more than 10, but the dictionary I look like and or normal operation And your function processLine () is no parameters, why you incoming parameters, will not be an error, this is very strange? ah, seemingly normal code is full of problems, I stroke first consult ha, ha, ha, saying the eldest brother I added you, did you forget to agree CodePudding user response:
At the very least to post code, send some test sample