if c == list:
is checking if c
is a type
i.e a list
also if if i > a and i < b:
never evaluates to True
you will never reach your return statement therefore by default return None
as all python functions do that don't specify a return value, I imagine you want something like:
Az = [5,4,25.2,685.8,435,2,8,89.3,3,794]
def azimuth(a,b,c):
new = []
if isinstance(c ,list):
for i in c:
if a < i < b:
new.append(i)
return new # return outside the loop unless you only want the first
Which can be simplified to:
def azimuth(a, b, c):
if isinstance(c, list):
return [i for i in c if a < i < b]
return [] # if c is not a list return empty list
If you want the index too use enumerate
:
def azimuth(a, b, c):
if isinstance(c, list):
return [(ind,i) for i, ind in enumerate(c) if a < i < b]
return []
If you want them separately:
def azimuth(a,b,c):
inds, new = [], []
if isinstance(c ,list):
for ind, i in enumerate(c):
if a < i < b:
new.append(i)
inds.append(ind)
return new,inds #
Then unpack:
new, inds = azimuth(10, 300, Az)