Write a Python function to check if a given element exists in a list. The function should return True if the element is found, otherwise return False.
Example 1:
Input: [1,2,3,4,5], 3
Output: True
Example 2:
Input: [1,2,3,4,5], 6
Output: False
You can use Python’s membership operators (in, not in) to check the existence of an element in a list.
def is_element_present(lst, element):
return element in lst
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.