Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to remove all 2 in a list python

x = [2, 1, 2]
while 2 in x:
  remove(2)
Comment

Remove multiple elements from a list in Python

# Python program to remove empty tuples from a
# list of tuples function to remove empty tuples
# using list comprehension
def Remove(tuples):
    tuples = [t for t in tuples if t]
    return tuples
 
# Driver Code
tuples = [(), ('ram','15','8'), (), ('laxman', 'sita'),
          ('krishna', 'akbar', '45'), ('',''),()]
print(Remove(tuples))
Comment

PREVIOUS NEXT
Code Example
Python :: python web parse 
Python :: python convert date to timestamp 
Python :: df dropna 
Python :: python read text file next line 
Python :: ssl django nginx 
Python :: % operatior in python print 
Python :: concatenate int to string python 
Python :: max of three numbers in python 
Python :: make a white image numpy 
Python :: find different between list 
Python :: TypeError: expected string or bytes-like object site:stackoverflow.com 
Python :: no module named pyinstaller 
Python :: apply lambda with if 
Python :: how to check if a list is nested or not 
Python :: create log in python 
Python :: root mean square python signal 
Python :: python cv2 convert image to binary 
Python :: del all variables python 
Python :: python code for where to save the figures 
Python :: how to remove a tuple from a list python 
Python :: python update 
Python :: find index of values greater than python 
Python :: find the highest 3 values in a dictionary. 
Python :: Find the title of a page in python 
Python :: line length in flake8 
Python :: how to count number of columns in dataframe python 
Python :: python 3 custom sort with compare 
Python :: check if variable is of type decimal.Decimal python 
Python :: pandas check match string lowercase 
Python :: iterate backwards through a list python 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =