list.remove
takes a single argument, which is the item you want to remove.
From the docs: https://docs.python.org/3/tutorial/datastructures.html
list.remove(x)
Remove the first item from the list whose value is equal to x. It raises a ValueError if there is no such item.
But "Maths, 76"
is not an element in your list, hence you get the error ValueError: list.remove(x): x not in list
So you want to remove each element one at a time
Marks = ['Amy', 'Jones', 'English', 72, 'Maths', 76, 'Computer Science', 96] Marks.remove("Maths") Marks.remove(76) print(Marks)
Or use a for loop
Marks = ['Amy', 'Jones', 'English', 72, 'Maths', 76, 'Computer Science', 96] for item in ["Maths", 76]: Marks.remove(item) print(Marks)
The output will be
['Amy', 'Jones', 'English', 72, 'Computer Science', 96]
Related Posts:
- TypeError: only size-1 arrays can be converted to Python scalars (matplotlib)
- Why do I get TypeError: can’t multiply sequence by non-int of type ‘float’?
- Writing a pandas DataFrame to CSV file
- When should I use uuid.uuid1() vs. uuid.uuid4() in python?
- ImportError: No module named tensorflow
- Best way to convert string to bytes in Python 3?
- How do you change the size of figures drawn with Matplotlib?
- PermissionError: [Errno 13] Permission denied
- How to find if directory exists in Python
- What is setup.py?
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- Cannot find module cv2 when using OpenCV
- What is the purpose and use of **kwargs? [duplicate]
- Error: all the input array dimensions except for the concatenation axis must match exactly
- Expected 2D array, got 1D array instead error
- How to prevent errno 32 broken pipe?
- The equivalent of a GOTO in python [duplicate]
- tkinter gui with progress bar
- Invalid character in identifier
- if else in a list comprehension
- What does “\r” do in the following script?
- Convert list to tuple in Python
- Python: TypeError: object of type ‘NoneType’ has no len()
- anaconda – path environment variable in windows
- Pandas: ValueError: cannot convert float NaN to integer
- How to find all occurrences of an element in a list
- pygame.error: video system not initialized
- TypeError: ‘numpy.float64’ object is not callable
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- How to find all the indexes of a recurring item in a list?
- Is there a way to delete created variables, functions, etc from the memory of the interpreter?
- Code for Greatest Common Divisor in Python
- ‘DataFrame’ object has no attribute ‘sort’
- How to check Django version
- How to change the font size on a matplotlib plot
- convert json ipython notebook(.ipynb) to .py file
- how to update spyder on anaconda
- Django upgrading to 1.9 error “AppRegistryNotReady: Apps aren’t loaded yet.”
- Pygame Drawing a Rectangle
- Purpose of `numpy.log1p( )`?
- How do I change the figure size for a seaborn plot?
- How to use pyinstaller?
- Contains of HashSet
in Python - How to take column-slices of dataframe in pandas
- Python: Get the first character of the first string in a list?
- How to make a 3D scatter plot in matplotlib
- Arrays used as indices must be of integer (or boolean) type
- How can I compare two lists in python and return matches
- How to draw vertical lines on a given plot in matplotlib
- Changing the “tick frequency” on x or y axis in matplotlib
- mysql_config not found when installing mysqldb python interface
- Importing variables from another file?
- Difference between BeautifulSoup and Scrapy crawler?
- Displaying better error message than “No JSON object could be decoded”
- “ImportError: No module named site” on Windows
- How do you read a file into a list in Python?
- How to find elements by class
- SSL error : routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
- What is the best way to call a script from another script?
- Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
- Euclidean Algorithm / GCD in Python
- Pandas split DataFrame by column value
- Using numpy to build an array of all combinations of two arrays
- Get a random sample with replacement
- Can’t update to numpy 1.13 with anaconda?
- Is there any simple way to benchmark Python script?
- Purpose of python antigravity module
- Error: “dictionary update sequence element #0 has length 1; 2 is required” on Django 1.4
- What is the Python equivalent of Matlab’s tic and toc functions?
- In Flask, what is “request.args” and how is it used?
- Conda command is not recognized on Windows 10
- pyserial, ImportError: No module named serial
- TypeError: only integer arrays with one element can be converted to an index 3
- In Flask, what is “request.args” and how is it used?
- How do I determine the size of an object in Python?
- Python function pointer
- Flask-SQLalchemy update a row’s information
- Inline for loop
- Read data (.dat file) with Pandas
- Is there any numpy group by function?
- Python way to clone a git repository
- List append() in for loop
- How to save an image locally using Python whose URL address I already know?
- How to throw error and exit with a custom message in python
- What is the correct format to write float value to file in Python
- How is Python’s List Implemented?
- ImportError: No module named IPython
- How to find length of digits in an integer?
- What exactly do “u” and “r” string flags do, and what are raw string literals?
- “E: Unable to locate package python3-pip”
- Eclipse, PyDev “Project interpreter not specified”
- How to exit an if clause
- Python a &= b meaning?
- Compare two columns using pandas
- ValueError: total size of new array must be unchanged
- Shuffle an array with python, randomize array item order with python
- No handlers could be found for logger
- TypeError: ‘NoneType’ object has no attribute ‘__getitem__’
- File “/usr/bin/pip”, line 9, in
from pip import main ImportError: cannot import name main