Write a function in Python, Push(SItem) where , SItem is a dictionary containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who have price greater than 75. Also display the count of elements pushed into the stack.
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain
Notebook
Pen
The output should be:
The count of elements in the stack is 2
Answer:
stack_items=[ ]
def
Push
(SItem):count=
0
for i in SItem:
if SItem[i]>=
75
:stack_items.append(i)
count=count+
1
print(
"The count of items in the stack: "
,count)