I am trying to return the difference of max and min of float items in the sequence. The output shall be an int, but the algorithm given below returns a list instead. Could someone let me know what I am missing?
def flatten(*args):
res = []
for el in args:
if isinstance(el,(tuple)):
if el != ():
res.extend(flatten(*el))
continue
else:
return "Empty"
res.append(el)
diff = [max(res)-min(res)]
return diff
>>> a
(1, 2)
>>> b
(1, (7, 8))
>>> flatten(a,b)
[1]