Write a function called onlyEvens(L) that accepts a list of integers (not in any sorted order) and returns a new list of integers where every
odd number has been replaced by 0.
Sample Input: [1, 5, 2, 3, 4]
Sample Output: [0, 0, 2, 0, 4]
def onlyEvens (L):
# TODO - use a loop to update L such that each odd numbers replaced by 0
return L
397094.2571770.qx3zqy7
LAB
ACTIVITY
11.2.1: LAB: Only Evens
1 def onlyEvens(L):
# TODO - your code goes here
2
3
4
5
6
7 if __name__ == '__main__':
8 result = onlyEvens ([3, 5, 6, 2, 10, 8])
9 print(result)
0/6
main.py
Load default template...