Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Use the "map" function to find all the odd numbers and the even numbers in the list. Print 0 for odd and 1 for even. in python

nums = [43, 20, 53, 12, 53, 5, 3, 2]

even = []
odd = []

for i in nums:
    if (i % 2 == 0):
        even.append(i)
    else:
        odd.append(i)

print("Even List: ", even)
print("Odd List: ", odd)
 
PREVIOUS NEXT
Tagged: #Use #function #find #odd #numbers #numbers #Print #odd #python
ADD COMMENT
Topic
Name
5+8 =