# Write code to read content from # https://storage.googleapis.com/cs1111/examples/file/todo.csv # then (print) display the file content on screen # Be sure to read from the Internet, # do not download the file to your computer import urllib.request url = "https://storage.googleapis.com/cs1111/examples/file/todo.csv" stream = urllib.request.urlopen(url) # print(stream) # print(type(stream)) # is_first_time = True count_am = 0 count_pm = 0 for line in stream: # print(line.decode('UTF-8')) decoded_line = line.decode('UTF-8').strip() print(decoded_line) items = decoded_line.split(",") if 'am' in items[1]: count_am += 1 elif 'pm' in items[1]: count_pm += 1 todo_dict = {'number_AM_todo':count_am, 'number_PM_todo':count_pm} print(todo_dict) # write more code to count the number of AM activities # and PM activities and print a todo_dict dictionary that # contains the numbers of activities # {'number_AM_todo': 4, 'number_PM_todo': 7}