I am having trouble with set operation intersection.
Assume I have a list A = [0,1,2,3]
, and an integer B = 0
. When I check if B in A:
, I am getting of course True
.
But when A
and B
are as default equal to None
, than I can't do the intersection operation of A
and B
.
I am looking for a way to do following without getting an error:
A = None
B = None
if B in A:
raise KeyError('B in A')
Normally A
is a python List and B
is a string. But I need to set them to None
as default, while they are arguments in my function; where they have to have a value of None
.
PS: Getting True
or False
with the search algo. is not important. I just need to get True
or False
, so that I can arrange my error-raising.