Python Forum
How to append multiple <class 'str'> into a single List
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to append multiple <class 'str'> into a single List
#2
In your loop where you're setting link_list, append it to a list that it outside the loop.

You've created such a list on line 41. But line 41 is useless because the variable is overwritten later by line 44.

Perhaps a bit more like...
            start = '="'
            end = '">'
            link_list = []
            for link in soup.findAll('a'):
                if "match_id" in link.get('href'):
                    link_list.append(str(link).split(start)[1].split(end)[0])
ahmedwaqas92 likes this post
Reply


Messages In This Thread
RE: How to append multiple <class 'str'> into a single List - by bowlofred - Jan-07-2021, 07:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  append str to list in dataclass flash77 6 345 Mar-14-2024, 06:26 PM
Last Post: flash77
  Can I use logging in a class (without multiple messages) mevan 2 535 Oct-16-2023, 11:08 PM
Last Post: mevan
  How to read module/class from list of strings? popular_dog 1 425 Oct-04-2023, 03:08 PM
Last Post: deanhystad
Question How to append integers from file to list? Milan 8 1,366 Mar-11-2023, 10:59 PM
Last Post: DeaD_EyE
  Create multiple/single csv file for each sql records mg24 6 1,325 Sep-29-2022, 08:06 AM
Last Post: buran
  read a text file, find all integers, append to list oldtrafford 12 3,372 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Reshaping a single column in to multiple column using Python sahar 7 1,970 Jun-20-2022, 12:35 PM
Last Post: deanhystad
  Using .append() with list vs dataframe Mark17 7 9,909 Jun-12-2022, 06:54 PM
Last Post: Mark17
  Split single column to multiple columns SriRajesh 1 1,290 Jan-07-2022, 06:43 PM
Last Post: jefsummers
  Delete multiple comments with a single API call (facebook) Ascalon 0 2,269 Dec-04-2021, 08:33 PM
Last Post: Ascalon

Forum Jump:

User Panel Messages

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