[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird Python Bug

For some reason, if you put in the code

def odd_ones_out(numbers):
    for num in numbers:
        count = numbers.count(num)
        if not count % 2 == 0:
            for i in range(count):
    return numbers

nums = [72, 4, 82, 67, 67]

For some reason, it outputs [4, 67, 67] when it should have deleted the 4 because it was odd. Another interesting thing is that when you put print(num) in the for loop, the number 4 never shows up and neither does the last 67. Help!