How to remove elements from a list that may or may not be present?

0 votes
In case I want to remove some element from my list and if I actually don't know whether that element is present or not what should I do?. I do not want to encounter an error even if the element is not present.
Jun 27, 2019 in Python by Nisa
• 1,090 points
94 views

No answer to this question. Be the first to respond.

Your answer

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

Related Questions In Python

0 votes
1 answer

How to remove the last object from a list?

Hi, @Roshni, Try running the following piece of ...READ MORE

answered Jun 26 in Python by Gitika
• 31,310 points
10 views
0 votes
1 answer

How to produce a list with unique elements from a list with duplicate elements?

Hey, @Roshni, Iterating the list is not a ...READ MORE

answered Jun 26 in Python by Gitika
• 31,310 points
27 views
0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2, 2019 in Python by Omkar
• 69,040 points
109 views
0 votes
1 answer

How to extract values from a string or a sequence?

you could use the statements like name[index value ...READ MORE

answered Mar 6, 2019 in Python by Waseem
• 4,530 points
53 views
0 votes
1 answer

How to remove the duplicate values in a list?

a = [10,20,30,40,10,20,30,40,30,40,50,60] s = set(a) c = list(s) print(c) this ...READ MORE

answered Mar 20, 2019 in Python by Mohammad
• 3,230 points
56 views
0 votes
1 answer

How to count the number of elements in a list?

To count the number of elements of ...READ MORE

answered May 27, 2019 in Python by Nisa
• 1,090 points
83 views
0 votes
2 answers

How do I remove an element from a list by index in Python?

Delete the List and its element: We have ...READ MORE

answered Jun 7 in Python by sahil
• 500 points
18,382 views
+1 vote
1 answer

How to convert records from csv to a list in Python?

If you are using Python 3.x then ...READ MORE

answered Jun 25, 2019 in Python by Arvind
• 2,980 points

edited Jun 26, 2019 by Kalgi 801 views
0 votes
2 answers
0 votes
1 answer

How to have values from a List1 into Columns Names and List 2 Values as Index for an Empty DataFrame

Try like this, it will give you ...READ MORE

answered Jul 10, 2019 in Python by Cherukuri
• 32,460 points
172 views