as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
write a function to find the most frequent element in an array.
user
def findmostfrequent(arr): 
    count_arr = {} 
    for i in range(len(arr)): 
        if arr[i] in count_arr: 
            count_arr[arr[i]] += 1
        else: 
            count_arr[arr[i]] = 1
    max_frequency = max(count_arr.values()) 
    for key,value in count_arr.items(): 
        if value == max_frequency: 
            return key
assistant