Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error message - help!
#4
(Mar-06-2017, 02:38 PM)Skippy Wrote: I am working on a program and this is what I have:
    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
During first iteration you overwrite your newSentence variable with a string, and a string has no append() method ...

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)   
Reply


Messages In This Thread
Error message - help! - by Skippy - Mar-06-2017, 02:38 PM
RE: Error message - help! - by Larz60+ - Mar-06-2017, 03:03 PM
RE: Error message - help! - by buran - Mar-06-2017, 03:06 PM
RE: Error message - help! - by zivoni - Mar-06-2017, 03:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error message about iid from RandomizedSearchCV Visiting 2 1,039 Aug-17-2023, 07:53 PM
Last Post: Visiting
  Another Error message. the_jl_zone 2 992 Mar-06-2023, 10:23 PM
Last Post: the_jl_zone
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,149 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  understanding error message krlosbatist 1 1,921 Oct-24-2021, 08:34 PM
Last Post: Gribouillis
  Error message pybits 1 42,479 May-29-2021, 10:26 AM
Last Post: snippsat
  f-string error message not understood Skaperen 4 3,363 Mar-16-2021, 07:59 PM
Last Post: Skaperen
  Overwhelmed with error message using pandas drop() EmmaRaponi 1 2,380 Feb-18-2021, 07:31 PM
Last Post: buran
  Winning/Losing Message Error in Text based Game kdr87 2 3,010 Dec-14-2020, 12:25 AM
Last Post: bowlofred
  Don't understand error message Milfredo 2 2,064 Aug-24-2020, 05:00 PM
Last Post: Milfredo
  what to do about this error message deric23 0 1,924 May-15-2020, 02:49 PM
Last Post: deric23

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020