Delete an element from a list : List Remove « List « Python






Delete an element from a list

Delete an element from a list
scores = ["1","2","3"]

# delete a score
score = int(raw_input("Delete which score?: "))
if score in scores:
   scores.remove(score)
else:
   print score, "isn't in the high scores list."

# list high-score table
for score in scores:
   print score

           
       








Related examples in the same category

1.List Delete: delete one item and delete an entire sectionList Delete: delete one item and delete an entire section
2.Deleting List ElementsDeleting List Elements
3.List: delete an elementList: delete an element
4.List: delete a slice :2List: delete a slice :2