0

I have to read in data line by line from a website. The first line of the website reads:

Take out the garbage, 5, May 8

I want to put this into a list with "Take out the garbage" separated from the "5" separated from the "May 8"

I am given this code to use:

 def readHtml():
    response = urllib.request.urlopen("#website")
    html = response.readline()
    data = html.decode('utf-8').split()

and I wanted to split it at the commas so that there would be no commas in the list so I added this after 'split' in the last line:

    data = html.decode('utf-8').split(',')

However when I try to print this it reads:

['Take out the garbage', ' 5', ' May 8\n']

with the weird \n after May 8 and strange spacing before May and before 5.

halfer
  • 19,824
  • 17
  • 99
  • 186
Lia
  • 45
  • 1
  • 1
  • 8

0 Answers0