-1

I am creating a function in python 3 by pulling HTML text from yahoo finance and using regular expressions so that once I enter a ticker symbol, the name of the company is returned. I am able to do so, however, when importing the company 'Macy's, Inc.', ['Macy's Inc'] is returned. Here is what I have tried so far to remove the '&#x27' and replace it with "'":

attempt 2

attempt 2

OneCricketeer
  • 151,199
  • 17
  • 111
  • 216
brrums
  • 1

1 Answers1

0

Use a list comprehension

return [x.replace('', "'") for x in name]

See also Decode HTML entities in Python string? for how to decode all HTML entities in a string, not just .

Barmar
  • 669,327
  • 51
  • 454
  • 560