मराठी

A list containing records of products as  L = [("Laptop", 90000), ("Mobile", 30000), ("Pen", 50), ("Headphones", 1500)] Pop_element() – To pop the items from the stack and display them. - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

A list containing records of products as 

L = [("Laptop", 90000), ("Mobile", 30000), ("Pen", 50), ("Headphones", 1500)]

Write the following user-defined function to perform an operation on a stack named Product to:

Pop_element() – To pop the items from the stack and display them. Also, display "Stack Empty" when there are no elements in the stack.

Output: 

('Headphones', 1500) 
('Mobile', 30000) 
('Laptop', 90000) 
Stack Emply
कोड लेखन
Advertisements

उत्तर

def Pop_element(product):
   while product:
     print(product.pop())
   else:
     print("Stack Emply")
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×