# deepfindEx.py
# Written by Todd Wareham for CS 2500
"""
Demonstration script for function deepfind(x, y) that returns true if
 non-sequence / dictionary / set item x is in nested list y and false
 otherwise.
"""

def deepfind(reqItem, givenList):
    if (type(reqItem) == type(givenList)):
        return reqItem == givenList
    elif type(givenList) != list:
        return False
    else: 
        for x in givenList:
            if deepfind(reqItem, x):
                return True
        return False
    
 

L = [1, [[2, 3], "4"], "5", [[[6]]]]

print ">>> L = ", L
print ' 0 ?: ', deepfind(0, L)
print '"0"?: ', deepfind("0", L)
print ' 1 ?: ', deepfind(1, L)
print '"1"?: ', deepfind("1", L)
print ' 2 ?: ', deepfind(2, L)
print '"2"?: ', deepfind("2", L)
print ' 3 ?: ', deepfind(3, L)
print '"3"?: ', deepfind("3", L)
print ' 4 ?: ', deepfind(4, L)
print '"4"?: ', deepfind("4", L)
print ' 5 ?: ', deepfind(5, L)
print '"5"?: ', deepfind("5", L)
print ' 6 ?: ', deepfind(6, L)
print '"6"?: ', deepfind("6", L)
print ' 7 ?: ', deepfind(7, L)
print '"7"?: ', deepfind("7", L)

