Write a function in Python PUSH(Num), where Num is a list of integer numbers.
From this list push all positive even numbers into a stack implemented by using a
list. Display the stack if it has at least one element, otherwise display appropriate
error message.
Answers
Answered by
4
PUSH = lambda Nums: [n for n in Nums if n > 1 and n % 2 == 0]
Nums = [-2, -4, 19, 10, 6]
new_l = PUSH(Nums)
print(new_l) if len(new_l) > 0 else print("empty list")
Answered by
0
PUSH = lambda Nums: [n for n in Nums if n > 1 and n % 2 == 0]
Nums = [-2, -4, 19, 10, 6]
new_l = PUSH(Nums)
print(new_l) if len(new_l) > 0 else print("empty list")
Similar questions