def delete_odd(num_list):
"""Removes all odd numbers from a list of numbers.
Args:
num_list (list): List of numbers to be checked.
Returns:
list: List of numbers with all odd numbers removed.
"""
new_list = list(num_list)
for num in new_list:
if num % 2 == 1:
new_list.remove(num)
return new_list
delete_odd([7, 65, 1337, 8, -2, 24, 6, 67, 54, 36, 25, 1, 42, 9, 138, 4356, 6])
When invoked, it returns this:
[65, 8, -2, 24, 6, 54, 36, 1, 42, 138, 4356, 6]
I have been working on this for some time now and can't seem to figure it out.