remove
doesn’t return anything. It modifies the existing list in-place. No assignment needed.
Replace
var = ['p', 's', 'c', 'x', 'd'].remove('d')
with
var = ['p', 's', 'c', 'x', 'd']
var.remove('d')
Now var
will have a value of ['p', 's', 'c', 'x']
.
More Related Contents:
- Why does append() always return None in Python? [duplicate]
- remove None value from a list without removing the 0 value
- Sort list while pushing None values to the end
- Can’t sort my list because it is NoneType? Simple Python [duplicate]
- How to make a dict from n’th indices of tuples in list
- Why does this code for initializing a list of lists apparently link the lists together? [duplicate]
- Slicing a list in Python without generating a copy
- Python list doesn’t reflect variable change
- What makes sets faster than lists?
- Check if two unordered lists are equal [duplicate]
- In Python, what is the fastest algorithm for removing duplicates from a list so that all elements are unique *while preserving order*? [duplicate]
- merging Python dictionaries
- Accessing the list while being sorted
- Modifying a list inside a function
- Python: How to remove empty lists from a list? [duplicate]
- How to get the n next values of a generator in a list (python)
- Converting a string that represents a list, into an actual list object
- Merging/adding lists in Python
- Flatten an irregular (arbitrarily nested) list of lists
- How to concatenate (join) items in a list to a single string
- How do I sort this list in Python, if my date is in a String?
- Convert all strings in a list to integers
- “TypeError: ‘type’ object is not subscriptable” in a function signature
- Ellipsis lists […] and concatenating a list to itself [duplicate]
- Python Sort One List According to Another List
- Creating sublists [duplicate]
- How to sort a list of dictionaries by a value of the dictionary in Python?
- Why Python `Memory Error` with list `append()` lots of RAM left
- How to create a nested dictionary from a list in Python?
- Store functions in list and call them later [duplicate]