Weird Python Bug
CrazyVideoGamez
jasonanyilian at gmail.com
Fri Sep 13 15:17:38 EDT 2019
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):
numbers.remove(num)
return numbers
nums = [72, 4, 82, 67, 67]
print(odd_ones_out(nums))
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!
More information about the Python-list
mailing list