0

This says input is an object of ET but isn't input a function? Besides, I never made an object named input so why is this happening?

What should I do to resolve this?

Code:

import xml.etree.ElementTree as ET
import urllib.request,urllib.parse,urllib.error

u=input('Enter Location:')
print("Retirieving ",u)

uh = urllib.request.urlopen(u)

data = uh.read()
print("Retrieved",len(data),"characters")

tree=ET.fromstring(data)

sum=0
c=0

counts = tree.findall('.//count')

for val in counts:
  sum+=int(val.text)
  c+=1

print("Count:",c)
print("Sum:",sum)

Error message:

TypeError                                 Traceback (most recent call last)
<ipython-input-19-af23c96a0ad5> in <module>
      2 import urllib.request,urllib.parse,urllib.error
      3 
----> 4 u=input('Enter Location:')
      5 print("Retirieving ",u)
      6 

TypeError: 'xml.etree.ElementTree.Element' object is not callable
  • 2
    Don't make us retype code from an image. Post all code, input, output, and error messages as plain text. – John Gordon Mar 26 '23 at 15:07
  • 1
    Looks like somewhere else in your code, you've used `input` as a variable name, so it can no longer be used to call the builtin Python input function. – slothrop Mar 26 '23 at 15:52
  • @slothrop but this is the complete code still its not working – Aaryan Joshi Mar 27 '23 at 12:26
  • @AaryanJoshi try restarting the notebook kernel? The only way you could get your error message from line 4 of your code is if `input` has been assigned in your session to refer to an etree element. As expected, when I paste your code into a fresh Colab notebook and run it, I don't get the error that you do. – slothrop Mar 27 '23 at 12:34

0 Answers0