I am trying to code a function where it compares all the strings within a list and checks if they are equivalent to another with the checking statement.
I want the answer to be True if 2 or more strings are equivalent if not False. How would i be able to modify checking so that it works with
numpy arrays instead of a normal list.
Code:
import numpy as np
def Checker(reader):
checking = any(s for s in set(reader) if reader.count(s) > 1)
print(checking)
reader = np.array(["cat", "dog", "cheetah", "giraffe", "monkey"])
reader2 = np.array(["cat", "dog", "cat", "giraffe", "monkey"])
reader3 = np.array(["cat","cheetah", "monkey"])
result = Checker(reader)
result2 = Checker(reader2)
result3 = Checker(reader3)
Error:
AttributeError: 'numpy.ndarray' object has no attribute 'count'
The result should list:
False
True
False