Your program will receive an array of complex numbers represented as strings. Your task is to write the  `complexSum` function which have to return the sum as a string.
Complex numbers can be written in the form of `a+bi`, such as `2-3i` where `2` is the real part, `3` is the imaginary part, and `i` is the "imaginary unit". 
When you add two complex numbers, the real and the imaginary part needs to be added separately,so for example `2+3i + 5-i = (2+5)+(3i-i) = 7+2i`
Both the complex and the imaginary part can be 0, so `123`, `-2i` or `i` are also complex numbers.
Complex numbers must be returned in their shortest form, so e.g. `0+1*i` should be just `i`, and `10+0i` should be `10`. This is also how you will get them!
For simplicity, the coefficients will always be integers. If the array is empty, return `0`.
Have fun! :)
def complexSum(arr):
    real_sum = 0
    imag_sum = 0
    for string in arr:
        val = ''
        for char in string:
            if char == '-':
                if len(val) > 0:
                    real_sum += int(val)
                val = '-'
            elif char == '+':
                real_sum += int(val)
                val = ''
            elif char == 'i':
                if val == '':
                    val = 1
                elif val[0] == '-':
                    if len(val) != 1:
                        val = -1 * int(val[1::])
                    else: val = -1
                imag_sum += int(val)
                val = 0
            else:   
                val += char
        real_sum += int(val)
    fin_string = ''
    if imag_sum == 1:
        fin_string = 'i'
    elif imag_sum == 0:
        fin_string = ''
    elif imag_sum == -1:
        fin_string = '-i'  
    else:
        if imag_sum > 1 and real_sum != 0:
            fin_string = '+'+str(imag_sum)+'i'
        else: 
            fin_string = str(imag_sum)+'i'
    if real_sum == 0 and imag_sum != 0:
        return fin_string
    return (str(real_sum)+fin_string) if (real_sum+imag_sum !=0) else '0'
def complexSum(arr):
    real_sum = 0
    imag_sum = 0
    for string in arr:
        val = ''
        for char in string:
            if char == '-':
                if len(val) > 0:
                    real_sum += int(val)
                val = '-'
            elif char == '+':
                real_sum += int(val)
                val = ''
            elif char == 'i':
                if val == '':
                    val = 1
                elif val[0] == '-':
                    if len(val) != 1:
                        val = -1 * int(val[1::])
                    else: val = -1
                imag_sum += int(val)
                val = 0
            else:   
                val += char
        real_sum += int(val)
    fin_string = ''
    if imag_sum == 1:
        fin_string = 'i'
    elif imag_sum == 0:
        fin_string = ''
    elif imag_sum == -1:
        fin_string = '-i'  
    else:
        if imag_sum > 1 and real_sum != 0:
            fin_string = '+'+str(imag_sum)+'i'
        else: 
            fin_string = str(imag_sum)+'i'
    if real_sum == 0 and imag_sum != 0:
        return fin_string
    return (str(real_sum)+fin_string) if (real_sum+imag_sum !=0) else '0'