Answers for "deleting elements from list python"

12

python how to remove item from list

list.remove(item)
Posted by: Guest on April-12-2020
1

python remove element from list

myList = ["hello", 8, "messy list", 3.14]  #Creates a list
myList.remove(3.14)                        #Removes first instance of 3.14 from myList
print(myList)                              #Prints myList
myList.remove(myList[1])                   #Removes first instance of the 2. item in myList
print(myList)                              #Prints myList


#Output will be the following (minus the hastags):
#["hello", 8, "messy list"]
#["hello", "messy list"]
Posted by: Guest on May-07-2021

Code answers related to "deleting elements from list python"

Python Answers by Framework

Browse Popular Code Answers by Language