मराठी

Write a function remove_element() in Python that accepts a list L and a number n. If the number n exists in the list, it should be removed. If it does not exist, - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

Write a function remove_element() in Python that accepts a list L and a number n. If the number n exists in the list, it should be removed. If it does not exist, print a message saying “Element not found”.

कोड लेखन
Advertisements

उत्तर

def remove_element(L, n):
  if n in L:
     L.remove(n)
     print(L)
  else:
     print("Element not found")
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×