Skip to content Skip to sidebar Skip to footer

Python: Function Takes Exactly 1 Argument (2 Given)

I have this method in a class class CatList: lista = codecs.open('googlecat.txt', 'r', encoding='utf-8').read() soup = BeautifulSoup(lista) # parse the list throug

Solution 1:

You forgot the self argument.

You need to change this line:

def parseList(tag):

with:

def parseList(self, tag):

You also got a global name error, since you're trying to access parseList without self.
While you should to do something like:

self.parseList(item)

inside your method.

To be specific, you need to do that in two lines of your code:

 return [self.parseList(item)

and

 return (tag.contents[0].string.strip(), self.parseList(tag.ul))

Post a Comment for "Python: Function Takes Exactly 1 Argument (2 Given)"