Hm sounds like you may have forgotten to remove the [:12] index from the other parts of your code where you use sentenceValue, maybe that is the issue? If not, feel free to share a snippet of your code so we can be on the same page.
The code should be like this..
for sentence in sentences:
for wordValue in freqTable:
if wordValue in sentence.lower():
if sentence in sentenceValue:
sentenceValue[sentence] += freqTable[wordValue]
else:
sentenceValue[sentence] = freqTable[wordValue]
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have changed it but it is still giving me some KeyError: and showing 3-4 starting lines from my text.
How to solve this error ?
Hm sounds like you may have forgotten to remove the [:12] index from the other parts of your code where you use
sentenceValue
, maybe that is the issue? If not, feel free to share a snippet of your code so we can be on the same page.Hi, I am still facing the same error index out of range...help me on this
The code should be like this..
for sentence in sentences:
for wordValue in freqTable:
if wordValue in sentence.lower():
if sentence in sentenceValue:
sentenceValue[sentence] += freqTable[wordValue]
else:
sentenceValue[sentence] = freqTable[wordValue]