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
#3
(Jan-07-2021, 07:02 AM)bowlofred Wrote: 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])

Thank you so much, it solved the problem as intended. Much appreciated :)
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Ploting single column with multiple category drunkenneo 1 360 May-26-2021, 04:51 PM
Last Post: jefsummers
  Better way to append frames from a video to multiple lists? Balaganesh 0 225 May-13-2021, 07:37 AM
Last Post: Balaganesh
  Parse String between 2 Delimiters and add as single list items lastyle 5 430 Apr-11-2021, 11:03 PM
Last Post: lastyle
  apendng to a list within a class gr3yali3n 4 385 Feb-16-2021, 06:30 AM
Last Post: buran
  convert List with dictionaries to a single dictionary iamaghost 3 522 Jan-22-2021, 03:56 PM
Last Post: iamaghost
  Inserting multiple rows in a single request. swaroop 2 483 Jan-11-2021, 01:34 PM
Last Post: swaroop
  Fetching data from multiple tables in a single request. swaroop 0 321 Jan-09-2021, 04:23 PM
Last Post: swaroop
  Undo interation to make a single list? DustinKlent 2 431 Nov-29-2020, 03:41 AM
Last Post: DustinKlent
  How to append to list a function output? rama27 5 856 Aug-24-2020, 10:53 AM
Last Post: DeaD_EyE
  Append list into list within a for loop rama27 2 732 Jul-21-2020, 04:49 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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