In this example, we will write a python function that will return the position of the only odd number within the number list. If there is no odd number within that list then the function will return -1 instead.
def odd_one(arr): for number in arr: if number % 2 != 0: return arr.index(number) return -1
The method above will loop through the number list to determine the position of the only odd number within that number list. If no odd number has been found then the method above will return -1!
That is a simple solution, if you have better idea then leave your comment below.
After a while of rest, I have begun to write again, I am planning to turn this website into a full tech website which will deal with programming, electronic gadget topic, and gaming. Feel free to subscribe to any