I want to check if a certain number exists in a nested list
Slist = [[[10, 20], [30, 40]], [[50, 60], [70, 80]]]
def ASearch(t, L):
if t==L:
return True
else:
return ASearch(t, L[0]) or ASearch(t, L[1])
ASearch(15,Slist)
What is the problem?
Update:
The OP meant to post this:
Slist = [[[10, 20], [30, 40]], [[50, 60], [70, 80]]]
def ASearch(t, L):
if t==L:
return True
return ASearch(t, L[0]) or ASearch(t, L[1])
print(ASearch(15, Slist))
print(ASearch(50, Slist))
Expected output:
False
True
Actual output:
TypeError: 'int' object is not subscriptable