Hi I'm getting the error TypeError: argument of type 'int' is not iterable when i run my program and don't know where I'm going wrong.

My code is:

class loan:

    global loanlist
    loanlist = []

    def loanbook(self, name, ISBN, author, title):
	self.name = name
	self.ISBN = ISBN
	self.author = author
	self.title = title
	self.data = loanlist.append(self.name)
	self.data = loanlist.append(self.ISBN)
	self.data = loanlist.append(self.author)
	self.data = loanlist.append(self.title)

class book:

    global booklist
    booklist = []

    def addbook(self, ISBN, author, title, stock):
	self.ISBN = ISBN
	self.author = author
	self.title = title
	self.stock = stock
	self.data = booklist.append(self.ISBN)
	self.data = booklist.append(self.author)
	self.data = booklist.append(self.title)
	self.data = booklist.append(self.stock)

class library:

    def issamebook(self, name, ISBN, author, title):
	for i in range(len(booklist)):
	    if ISBN in booklist[i]:
	        if author in booklist[i+1]:
		    if title in booklist[i+2]:
		        print "Found book match at position ", i
			booklist[i+3] = booklist[i+3] - 1
		        print "book not found"

if __name__ == "__main__":
    a.addbook("1234", "John", "Book 1", 1)
    a.addbook("2345", "Jim", "Book 2", 1)
    print booklist
    b.loanbook("Steven", "1234", "John", "Book 1")
    b.loanbook("Tom", "2345", "Jim", "Book 2")
    print loanlist
    c.issamebook("Steven", "1234", "John", "Book 1")
    print booklist

Can someone give me a clue on what to do. Thanks.

I forgot to mention the error message occurs on line 35.

What i am trying to do in the issamebook function is search for the ISBN number of the book and then look at the next 2 items in the list after the ISBN number which has been found and see if they match the author and title of the book. I then am trying to reduce the stock by one as if the person has taken the book out of the library.

I now have this working. Thanks.

First of all, you are mixing spaces and tabs in your indentations, which will srew up most editors. Please use spaces only!

I assume the error happens in the for loop, and it looks like when you reach the integer element in your booklist you are trying to use "in" to compare a string with an integer.

Solution, have your for loop go in steps of 4 like this:
for i in range(0, len(booklist), 4):

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.