Computer Science, asked by shivamchouhan07, 4 months ago

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 jai696
4

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

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")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Answered by satyam21461
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