Rocode
Rocode

Reputation: 118

if ( "compare string " and "compare int ")

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'

Upvotes: 0

Views: 82

Answers (1)

Ray Toal
Ray Toal

Reputation: 88468

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.

Upvotes: 1

Related Questions