Instagram
youtube
Facebook
Twitter

Python Program to Delete Given Element from List

   A Python Program to Delete Given Element from List 
   Code Description:
   This Python program deletes a specific element (33) from a given list if it exists.
   Explanation:

• A list of numbers is defined.
• The element to be deleted (33) is stored in a variable.
• The program checks if the element is present in the list using in.
• If found, it removes the element using remove() method.
• It then prints the updated list.
• If not found, it shows a message: "Element not found in the list."


Program:

my_list = [11,22,33,44,55,66,77,88,99,100]

element = int(input('Enter a number: '))

if element in my_list:

    my_list.remove(element)

    print("Update my list: ",my_list)

else:

    print("This element not in list: ",my_list)