1
['New Zealand',
 'England',
 'Australia',
 'India',
 'South Africa',
 'Pakistan',
 'Bangladesh',
 'West Indies',
 'Sri Lanka',
 'Afghanistan',
 'Netherlands',
 'Ireland',
 'Oman',
 'Scotland',
 'Zimbabwe',
 'Nepal',
 'UAE',
 'United States',
 'Namibia',
 'Papua New Guinea',
 '',
 '',
 '',
 '',
 team = soup5.find_all("span",class_='u-hide-phablet')

team_name = []

for i in team:

    team_name.append(i.text)

i was webscraping icc top ten team in this output i want to remove empty list please help me

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252

1 Answers1

0

Use if i:

for i in team:
    if i:
        team_name.append(i.text)

If that doesn't work use:

for i in team:
    if i.text:
        team_name.append(i.text)
U13-Forward
  • 69,221
  • 14
  • 89
  • 114