If i would do it like that, it will return None if the first row is not with the given vnum :o
"You can do it too, here is just a example."
I not say to delete the loop, i just showed a better option to return on situation because you did return color, return None etc, isn't compatible on this case my example from quoute of course with your loop
- if itemVnum >= fromVnum and itemVnum <= toVnum:
- return color
- return None
I say you can do it simple like this: (I'm speaking just about returning mode
- return color if itemVnum is (itemVnum >= fromVnum and itemVnum <= toVnum) else None
Zitat von Sanii
I want to know if theres a better way to check if it is existing in the array.
I can give you a better option for a dict elements and you can play with this more funny
- def Lookup(conjugateDict, *kwargs):
- endOfChain = conjugateDict
- for keyData in kwargs:
- if isinstance(endOfChain, dict) and keyData in endOfChain:
- endOfChain = endOfChain[keyData]
- else:
- return None
- return endOfChain
Zitat von Sanii
And maybe i could do: if itemVnum in range(fromVnum, toVnum+1): but i dont like this +1 xD
- import numpy
- if (numpy.any((fromVnum <= itemVnum) & (itemVnum <= toVnum))):
I hope you get my points, i just speaking about more good practices, on progamming never exist a final version of code, everytime we can extended it.
Good luck.