Deleting a list element by value

0 votes
How can we delete an element in a list if the value to be deleted is given?
May 11, 2018 in Python by kaalabilli
• 1,090 points
9 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Use the remove() function:

>>> p = [1, 2, 3, 4, 5]
>>> p.remove(3)
>>> p
[1, 2, 4, 5]
answered May 11, 2018 by Hamartia's Mask
• 1,580 points

Related Questions In Python

0 votes
1 answer

Deleting a list element by index

Use the del() function del a[2] Or you can ...READ MORE

answered Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
14 views
0 votes
1 answer

How do I sort a dictionary by value?

It is not possible to sort a ...READ MORE

answered Jul 30, 2018 in Python by Priyaj
• 56,120 points
14 views
0 votes
2 answers

In List of Dicts, find min() value of a common Dict field

lst = [{'price': 99, 'barcode': '2342355'}, {'price': ...READ MORE

answered Aug 31, 2018 in Python by Omkar
• 65,840 points
53 views
0 votes
1 answer

In Python, how do I read a file line-by-line into a list?

with open(fname) as f:     content = f.readlines() # you ...READ MORE

answered Oct 9, 2018 in Python by SDeb
• 9,460 points
62 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
20 views
+4 votes
6 answers
0 votes
1 answer

Remove duplicate elements in a list

Here is the code for this - list(set((list_of_numbers) For ...READ MORE

answered May 11, 2018 in Python by Hamartia's Mask
• 1,580 points
13 views
0 votes
1 answer

Extract element from a set without removing it

Use iter(): element = next(iter(set_1)) READ MORE

answered Jun 7, 2018 in Python by Hamartia's Mask
• 1,580 points
8 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.