Assuming you mean “list” where you say “array”, you can do
if item in my_list:
# whatever
This works for any collection, not just for lists. For dictionaries, it checks whether the given key is present in the dictionary.
More Related Contents:
- ValueError: setting an array element with a sequence
- Numpy `logical_or` for more than two arguments
- Quick way to upsample numpy array by nearest neighbor tiling [duplicate]
- How to copy a 2D array into a 3rd dimension, N times?
- How do I convert a numpy array to (and display) an image?
- How does NumPy’s transpose() method permute the axes of an array?
- Numpy random choice to produce a 2D-array with all unique values
- How do I print the full NumPy array, without truncation?
- Multiplying across in a numpy array
- initialize a numpy array
- numpy array assignment problem
- What does dtype=object mean while creating a numpy array?
- Python Numpy TypeError: ufunc ‘isfinite’ not supported for the input types
- Why is a `for` over a Python list faster than over a Numpy array?
- Subtracting numpy arrays of different shape efficiently
- Selecting close matches from one array based on another reference array
- Why does numpy have a corresponding function for many ndarray methods?
- Numpy sub-array assignment with advanced, mixed indexing
- Efficiently sorting a numpy array in descending order?
- Numpy: Divide each row by a vector element
- How to sort multidimensional array by column?
- Setting the fmt option in numpy.savetxt
- How do I compute all possibilities for an array of numbers/bits (in python, or any language for that matter)
- Numpy shuffle multidimensional array by row only, keep column order unchanged
- Randomly select from numpy array
- How to “scale” a numpy array?
- How to create an array of bits in Python?
- Convert binary string to bytearray in Python 3
- Generate random array of floats between a range
- Numpy `ValueError: operands could not be broadcast together with shape …`