0

compared two strings inside the if statement and used " and " operator then compared two integers.

 if( issue == bk[i].name and bk[i].quan !=0 ):
            print " book is available"

I get this error

Traceback (most recent call last):
  File "C:\Users\DCC PCMC\Desktop\CSE\python projects\DSA project\lib_class.py", line 141, in                                      <module>
    if( issue == bk[i].name and bk[i].quan !=0 ):
AttributeError: 'int' object has no attribute 'name'
2
  • bk[i] is int your sequence b. I guess It should be some book object in your list b you have overwritten in your code before if statement: Add more code here. or your assignment is wrong. I think bk[i].name should be assigned in bk[i].quan Commented Aug 18, 2013 at 6:17
  • Can you edit your question to include an example of the structure of the bk list? Commented Aug 18, 2013 at 17:05

1 Answer 1

1

The error message is pretty clear.

It is telling you you have an int with no attribute name.

Where do you use name? You use it here:

bk[i].name

So it must be the case that the value of bk[i] is an int. You probably expected it to be something else.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.