I am new to Python so bear with me here. My evenList is not being populated for some reason. I know the loop is executing because when I add a print statement under my if then it prints 4 times. My oddList is appending just fine.
def find_outlier(integers):
evenList = []
oddList = []
for i in range(len(integers)):
if (integers[i] % 2) == 0:
evenList.append(integers[i])
else:
oddList.append(integers[i])
if len(evenList) < len(oddList):
print(evenList[0])
else:
print(oddList[0])
testList = [2,6,8,10,3]
find_outlier(testList)
Aucun commentaire:
Enregistrer un commentaire