-1

I have a list part of an if clause:

 if context and a in b :

If the list is empty I receive the following error:

ValueError: invalid literal for int() with base 10: ''

I can check if the list is empty with no issues with no errors using:

   if not context:

But I need the vice-versa working. I tried also

if context is not None

but the same error. I don't understand why using not is working and without is not working.

user3541631
  • 3,686
  • 8
  • 48
  • 115

1 Answers1

3

if context is not None is comparing the object reference to 'None', not checking if the object itself is empty. This post may help you understand it better.