Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers.

Return your answer as a number.

Difficulty: introductory

Starter code:

def sum_mix(arr):
	

Solutions:
def sum_mix(arr):
    return sum(map(int, arr))

def sum_mix(arr):
    return sum(int(n) for n in arr)

def sum_mix(arr):
    result = 0
    for a in arr:
        try:
            result += a
        except TypeError:
            result += int(a)
    return result

def sum_mix(arr):
    return sum(int(i) for i in arr)

from functools import reduce

def to_int(num):
    "convert to int digit or string"
    try:
        return int(num)
    except ValueError:
        return 0

def sum_mix(arr):
    """
    Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers.
    Return your answer as a number.

    :param arr: [9, 3, '7', '3']
    :return: 22
    """
    converted_array = list([to_int(x) for x in arr])
    return reduce(lambda res, x: res + x, converted_array)


def sum_mix(arr):
    return sum([int(i) for i in arr])

sum_mix = lambda a: sum(map(int, a))

def sum_mix(arr):
    return sum(int(x) for x in arr)

def sum_mix(arr):
    somme = 0
    for i in arr:
        somme += int(i)
    return somme;

sum_mix = lambda A: sum( [int(n) for n in A] )


def sum_mix(arr):
  L = []
  for i in arr:
    L.append(int(i))
  return sum(L)

def sum_mix(arr):
    return sum(float(x) for x in arr)

def sum_mix(arr):
    return eval('+'.join(str(x) for x in arr))

def sum_mix(arr):
    return sum([float(x) for x in arr])
    #your code here


def sum_mix(arr):
    arr_int = [int(el) for el in arr]
    return sum(arr_int)

def sum_mix(arr):
    sum = 0
    for i in arr:
        if type(i) != int:
            sum += int(i)
        else:
            sum += i
    return sum

from functools import reduce
def sum_mix(arr):
    #your code here
    return reduce((lambda x,y: int(x)+int(y)),arr)

def sum_mix(arr):
    return sum(int(item) for item in arr)

def sum_mix(arr):
    sum_ = 0
    for item in arr:
        if isinstance(item, (str)):
            sum_ += int(item)
        elif isinstance(item, (int, float)):
            sum_ += item
    return sum_

def sum_mix(arr):
    return sum(int(num) for num in arr)

def sum_mix(arr):
    li = []
    for i in arr:
        li.append(int(i))
    return sum(li)

def sum_mix(arr):
    #your code here
    return sum(list(map(int,arr)))

def sum_mix(arr):
    total = 0
    for i in map(int, arr):
        total += i
    return total


def sum_mix(arr):
    b = []
    for i in arr:
         b.append(int(i))
    return sum(b)

def sum_mix(arr):
    result = 0
    for number in arr:
        result += int(number)
    return result

def sum_mix(arr):
  sum = 0
  for element in arr:
    sum = sum + int(element)
  return sum

def sum_mix(arr):
    sum=0
    for i in arr:
        sum+= int(i)
    return sum

def sum_mix(arr):
    for i in range(0, len(arr)): 
        arr[i] = int(arr[i])
        
    suma = sum(arr)
    return suma

def sum_mix(arr):
    return sum(int(arr[num]) for num in range(len(arr)))


def sum_mix(arr):
    arr= [int(i) for i in arr]
    sum = 0
    for i in arr:
        sum += i
    return sum


sum_mix = lambda array: sum([int(x) for x in array])

def sum_mix(arr):
    ans = 0
    for k in arr:
        ans += int(k)
        
    return ans
    #your code here


def sum_mix(arr):
    result = [int(item) for item in arr]
    return (sum(result))


def sum_mix(arr):
    #your code here
    numbers = arr
    sum = 0
    for num in numbers:
        number = int(num)
        sum += number
    return sum

def sum_mix(arr):
    total = 0
    for num in arr:
        if type(num) == str:
            total += int(num)
        else: 
            total += num
        
    return total

def sum_mix(arr):
    count = 0
    for i in arr:
        if type(i) == 'str': count += int(i)
        else: count += int(i)
    return count

sum_mix = lambda arr : sum([int(digit) for digit in arr])

def sum_mix(arr):
    suma=0
    for x in arr:
        y=int(x)
        suma=suma+y
    return suma
        


def sum_mix(arr):
    tam = len(arr) #Tamanho do array
    num = 0
    soma = 0
    
    for num in range(tam): #Separar cada elementro do array
        y = int(arr[num])
        num = num + 1
        soma += y #soma o último valor com a variável atual

    return soma
    #your code here


def sum_mix(arr):
    #your code here
    lst = [int(x) for x in arr]
    return sum(lst)

def sum_mix(arr):
    #your code here
    sum=0
    for i in range(len(arr)):
        if(arr[i] is int):
            sum+=0
        else:
            sum+=int(arr[i])
    return sum

def sum_mix(arr):
    sum = 0
    for lmnt in arr:
        sum += int(lmnt)
    return sum

def sum_mix(arr):
    lst = list(map(int, arr))
    return sum(lst)


def sum_mix(numbers):
    return sum(int(n) for n in numbers)

def sum_mix(arr):
    tot = 0
    for i in range(len(arr)):
        if type(arr[i]) is str:
            x = int(arr[i])
            tot += x
        else:
            tot += arr[i]
    return tot


def sum_mix(arr:[]):
    result = 0
    for i in arr:
        if isinstance(i,str):
            result += int(i)
        else:
            result += i
    return result


def sum_mix(arr):
    return sum(int(n) if type(n) == str else n for n in arr)

def sum_mix(arr):
    c = 0
    ls = []
    for i in arr:
        c=int(i)
        ls.append(c)
    return sum(ls)
    #your code here


def sum_mix(arr):
    nums=[]
    for i in arr:
        i = int(i)
        nums.append(i)
        
    return sum(nums)

def sum_mix(arr):
    res = 0
    for el in arr:
        res += int(el)
    return res

def sum_mix(arr):
    """(^-__-^)"""
    count = 0
    for i in arr:
        count += int(i)
    return count


import unittest


def sum_mix(input_array):
    return sum(int(element) if isinstance(element, str) else element for element in input_array)


class TestSumMix(unittest.TestCase):
    def test_sum_mix_with_elements_are_only_integer(self):
        self.assertEqual(sum_mix([8, 0, 0, 8, 5, 7, 2, 3, 7, 8, 6, 7]), 61)

    def test_sum_mix_with_elements_are_only_string(self):
        self.assertEqual(sum_mix(["1", "2", "3", "4", "5"]), 15)

    def test_sum_mix_with_elements_are_integers_or_string(self):
        self.assertEqual(sum_mix(["1", 2, "3", 4, "5"]), 15)


def sum_mix(arr):
    ans = []
    for i in arr:
        ans.append(int(i))
    return sum(ans)

def sum_mix(arr):
    messages = []
    
    for i in arr:
        messages.append(int(i))
        
    return sum(messages)

def sum_mix(arr):
    res = 0
    for num in arr:
        if isinstance(num, str):
            res += int(num)
        else:
            res += num
    return res

def sum_mix(arr):
    x = 0
    for i in range(len(arr)):
        x = x + int(arr[i])
    return x

def sum_mix(arr):
    acc = 0
    for i in arr:
        acc += int(i)
    return acc

def sum_mix(arr):
    temp = [int(i) for i in arr]
    return sum(temp)

def sum_mix(arr):
    return sum(map(int, (n for n in arr)))

def sum_mix(arr):
    for  i,el in enumerate(arr):
        if isinstance(el,str):
            arr[i]=int(el)
    return sum(arr)

def sum_mix(arr):
    arr_list = [int(x) for x in arr]
    return sum(arr_list)

def sum_mix(arr):
    suuum = 0
    for i in arr:
        suuum += int(i)
    return suuum

def sum_mix(arr):
    arr= sum([int(x)for x in arr])
    return arr

def sum_mix(arr):
    new_arr = list(map(int,arr))
    return sum(new_arr)

def sum_mix(arr):
    
    #start with a running total of zero
    total = 0
    
    #first convert all to int form
    # then add to running total
    for i in range(len(arr)):
        arr[i] = int(arr[i])
        total = total+arr[i]
            
            
    return(total)
    
    #your code here


sum_mix = lambda a: sum(int(a) for a in a)

def sum_mix(arr):
    transformed = [int(x) for x in arr]
    return sum(transformed)

def sum_mix(arr):
    nn = 0
    for a in arr:
        nn += int(a)
    
    return nn

def sum_mix(arr):
    s=0
    for ele in arr:
        if ele is not int:
            ele=int(ele)
            s+=ele
    return s

def sum_mix(arr):
   #your code 
    b = [int(i) for i in arr]
    c = sum(b)
    return c


def sum_mix(arr):
    #your code here

    suma = int(0)
    for i in range(0, len(arr)): 
        arr[i] = int(arr[i]) 
    for i in arr:
        suma += i
    return suma      



def sum_mix(array):
    new_array=[]
    for x in array:
        x=int(x)
        new_array.append(x)
    return sum(new_array)


def sum_mix(arr):
    new_list = []
    for x in arr:
        new_list += [int(x)]
    return sum(new_list)

def sum_mix(arr):
    c=0
    for i in arr:
        i=int(i)
        c+=i
    return c
        
    #your code here


def sum_mix(arr):
    #your code here
    intarr = [int(i) for i in arr] 
    sumarr = sum(intarr)
    return sumarr

import functools

def sum_mix(arr):
    print(arr)
    
    return functools.reduce(lambda x, y : int(x) + int(y) ,arr)


def sum_mix(arr):
    suma = 0
    for i in arr:
        if type(i) == int:
            suma += i
        else:
            suma += int(i)
    return suma

def sum_mix(arr):
    new_arr=[]
    for x in arr:
        if type(x)==str:
            new_arr.append(int(x))
        elif type(x)==int:
            new_arr.append(x)
    return sum(new_arr)

def sum_mix(arr):
    cont=0
    for i in arr:
        cont+=int(i)
    return cont

def sum_mix(arr):
    #your code here
    n=0
    for a in arr:
        if type(a)==int:
            n+=a
        elif type(a)==str:
            n+=int(a)
    return n
            


def sum_mix(arr):
    suma = 0
    for number in arr:
        suma += int(number)
    return suma
    #your code here


def sum_mix(arr):
    sum = 0
    for i in range(len(arr)):
        if isinstance(arr[i], str): sum += int(arr[i])
        else: sum += arr[i]
            
    return sum

def sum_mix(arr):
    t = 0
    for i in arr:
        if isinstance(i, str):
            t +=int(i)
        else:
            t +=i
    return t

from functools import reduce
def sum_mix(arr):
    return sum([int(i) for i in arr])

from functools import reduce
def sum_mix(arr):
    return sum(map(int,arr))

from functools import reduce
def sum_mix(arr):
    return reduce(lambda x,y: x + (y if y is int else int(y)), arr, 0)

def sum_mix(arr):
    a = [int(a)for a in arr]
    return sum(a)


def sum_mix(arr):
    total = ""
    new_lst = []
    for i in arr:
        if i == str(i):
            new_lst.append(int(i))
        else:
            new_lst.append(i)
    total = sum(new_lst)
    return total



def sum_mix(arr):
    i = 0
    array_numbers = []
    for i in range(len(arr)):
        array_numbers.append(int(arr[i]))
        i = i + 1
    return sum(array_numbers)

def sum_mix(arr):
    sum = 0
    for x in arr:
        if type(x) == str:
            x = int(x)
            sum = sum + x
        else:
            sum = sum + x

    return sum

def sum_mix(arr):
    a = 0
    for el in arr:
        if el == int(el):
            a += el
        elif el == str(el):
            el = int(el)
            a += el
    return a

def sum_mix(arr):
    liczby = []
    for a1 in arr:
        liczby.append(int(a1))
    return sum(liczby)

def sum_mix(arr):
    sum = 0
    numbers = [int(x) for x in arr]
    
    for i in numbers:
        sum = sum + i
    
    return sum
       


def sum_mix(arr):
    sum=0
    for x in arr:
        if type(x)==str:
            x=int(x)
            sum+=x
        else:
            sum+=x
    return sum
    



def sum_mix(arr) -> int:
    return sum([int(x) for x in arr])

def sum_mix(arr):
    sum = 0
    for i in arr:
        if type(i) == str :
            i = int(i)
            sum += i
        else:
            sum += i
            
    return sum

def sum_mix(arr):
    sum = 0
    for elem in arr:
        sum = sum + int(elem)
    return sum

def sum_mix(arr):
    numbers = 0
    for items in arr:
        numbers+= int(items)
    return numbers
        


def sum_mix(arr):
    list=[]
    for x in arr:
        if isinstance(x, str):
            list.append(int(x))
        if isinstance(x, int):
            list.append(x)
    return sum(list)
    #your code here