Mar-06-2017, 03:08 PM
(Mar-06-2017, 02:38 PM)Skippy Wrote: I am working on a program and this is what I have:During first iteration you overwrite your newSentence variable with a string, and a string has no append() method ...
for i in positions: newSentence.append(uniqueWords[i-1]) newSentence = " ".join(newSentence) # <-- newSentence is not a list anymore, so previous row will raise error on next word
Perhaps you dont want to concatenate words in newSentence until the end of the iteration over uniqueWords? In that case removing indentation could help (i didnt check rest of function):
for i in positions: newSentence.append(uniqueWords[i-1]) newSentence = " ".join(newSentence)