'TypeError: 'int' object is not callable' in python3 using BeautifulSoup

I am trying to get sum of some number from a web page.And all number is inside span tag.
This is the webpage - http://py4e-data.dr-chuck.net/comments_42.html
And here is my code:

# To run this, download the BeautifulSoup zip file
# http://www.py4e.com/code3/bs4.zip
# and unzip it in the same directory as this file

from urllib.request import urlopen
from bs4 import BeautifulSoup
import ssl
sum = 0
li = []
# Ignore SSL certificate errors
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

url = input('Enter - ')
html = urlopen(url, context=ctx).read()
soup = BeautifulSoup(html, "html.parser")

# Retrieve all of the span tags
tags = soup('span')
for tag in tags:
#x = list(map(int,li))

But i am getting an error is ‘TypeError: ‘int’ object is not callable’.
Here is my screenshot:

Can you please help me to figure out why this happening ?

You replaced the sum function with an integer, which means that you can’t call the sum function.

1 Like

Always found myself dumb :roll_eyes:

I noticed it right away because I’ve done it to myself before!

1 Like