Please check my code here: Sample url: http://py4e-data.dr-chuck.net/comments_42.html Sum of the digits found in following url should be (2553). I have to tried to sum up using several techs but can't find the correct one use the url provided at the top of the code. I need to sum up the strings numbers.
import urllib
from urllib.request import urlopen
from bs4 import BeautifulSoup
import ssl
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
# To read the file from the url
url = input('Enter - ')
html = urllib.request.urlopen(url, context=ctx).read()
soup = BeautifulSoup(html, "html.parser")
# To search for specific area of the file
tags = soup('span')
#print(tags)
sum = 0
# Filters your search further and prints the specific part as                     
#string
for tag in tags:
    print(tag.contents[0])
    #ChangeToInt = int(tag.contents[0])
    #sum =+ ChangeToInt
    #print(sum)
 
     
    