Home > Enterprise >  TypeError: '>' not supported between instances of 'tuple' and 'int'
TypeError: '>' not supported between instances of 'tuple' and 'int'

Time:06-20

Hi I am checking this two tuple to see if they are above zero but i am getting this error how i can check that,

a=(4,5)
b=(6,7)
if a>0 and b>0:
  print(8)

CodePudding user response:

a=(4,5)
b=(6,7)

for x in a range(0,2)
  if(a[x] < 0 || b[x] < 0){
     print(8)
  }

You can not directly check all elements inside a tuple like you are doing because tuple itself isn't an integer it is a list like object

CodePudding user response:

https://stackoverflow.com/questions/41832551/difference-between-tuple-and-int-and-error-unorderable-types-tuple-int#:~:text=A tuple is an immutable,), and exactly one item.

  • Related