def test_search_n(): l = ['test', 4, 2.8, 'text'] x = 2.8 x1 = 23 x2 = 'test' assert func.search_n(l, x) == (2, x) assert func.search_n(l, x1) == (None, None) assert func.search_n(l, x2) == (0, x2)
def search_n(l, x): result = functions.search_n(l, x) if result == (None, None): raise ValueError("%s not found" % x) return result
def search_n(l, x): """ Returns the position of x in list l and the value of x. Parameters ---------- l : list x : int, float or str Returns ------- i : int Position of x in list l. val : int, float or str Value of x. """ i, val = func.search_n(l, x) # raise an error if x is not contained in the list if i is None: raise ValueError return i, val
def search_n(liste,x): sn = fu.search_n(liste,x) if sn[1]==None: raise ValueError() else: return sn
def search_n(liste, x): sn = fu.search_n(liste, x) if sn[1] == None: raise ValueError() else: return sn