## Find Mean

Find the mean (average) of a list of numbers in an array.

## Information

To find the mean (average) of a set of numbers add all of the numbers together and divide by the number of values in the list.

For an example list of `1, 3, 5, 7`

1. Add all of the numbers

```
1+3+5+7 = 16
```

2. Divide by the number of values in the list. In this example there are 4 numbers in the list.

```
16/4 = 4
```

3. The mean (or average) of this list is 4

Difficulty: introductory

Starter code:

def find_average(nums):
	

Solutions:
def find_average(nums):
    return float(sum(nums)) / len(nums) if len(nums) !=0 else 0

def find_average(nums):
    return sum(nums) / float(len(nums)) if nums else 0

def find_average(nums):
    return sum(nums) / len(nums) if nums else 0

import numpy

def find_average(nums):
    return numpy.mean(nums) if nums else 0

def find_average(nums):
    try:
        return sum(nums) * 1.0 / len(nums)
    except:
        return 0

from numpy import mean

def find_average(nums):
  return mean(nums or [0])

import numpy as np

find_average = lambda x: np.mean(x or 0)

import numpy as np
def find_average(N):
    return 0 if len(N)<1 else np.mean(N)


find_average = lambda n: sum(n) / float(len(n)) if len(n) > 0 else 0

def find_average(N):
  return 0 if not N else sum(N)/float(len(N)) 


find_average = lambda n: float(sum(n)) / len(n) if n else 0

find_average = lambda nums: 0 if not nums else sum(nums) / (len(nums) + .0)

def find_average(nums):
   return sum(nums) / len(nums) if len(nums) else 0

from numpy import mean
def find_average(N):
    return 0 if len(N)<1 else mean(N)


from numpy import mean 
def find_average(nums):
    if nums:
        return mean(nums)
    return 0

from numpy import mean

def find_average(nums):
    return mean(nums) if nums else 0

find_average = lambda nums: sum(nums) / float(len(nums) or 1)

find_average=lambda nums: 1.0*sum(nums)/len(nums) if len(nums) else 0

def find_average(nums):
    return int(nums != []) and float(sum(nums))/len(nums)

def find_average(nums):
    return __import__('statistics').mean(nums) if nums else 0

find_average = lambda a: __import__("numpy").mean(a) if a else 0

from typing import List, Union

def find_average(nums: List[int]) -> Union[int, float]:
    """ Get the mean (average) of a list of numbers in an array. """
    return sum(nums) / len(nums) if nums else 0

def find_average(nums):
    return 0 if len(nums) < 1 else sum(nums) / len(nums) 

def find_average(nums):
    try:
        return float(sum(nums)) / len(nums)
    except ZeroDivisionError:
        return 0

def find_average(nums):
    return nums!=[] and sum(nums) / len(nums)

def find_average(nums):
    return sum(nums) / (len(nums) + 0. or 1.)

def find_average(nums):
    return sum(nums)/float(max(1,len(nums)))

def find_average(nums):
    if len(nums) == 0:
        return 0
    return float(sum(nums)) / float(len(nums))
    #your code here


def find_average(nums):
    items = 0
    total = 0.0
    for a in nums:
        items += 1
        total += a
    return 0 if items == 0 else total / items


# def find_average(nums):
    # length = len(nums)
    # return sum(nums) / float(length) if length > 0 else 0


def find_average(nums):
    a = sum(nums)
    b = len(nums)
    
    if (a == 0) or (b == 0):
        return 0
    else:
        return(a/b)

def find_average(nums):
    return 0 if not len(nums) else sum(nums)/len(nums)

def find_average(nums):
    #your code here
    total = 0
    if len(nums) > 0:
        for i in nums:
            total += i 
        le = len(nums)
        print((total/le))
        return total/le
    else: 
        return 0


find_average = lambda a: sum(a)/len(a) if a else 0 

def find_average(nums):
    nb = len(nums)
    return nb != 0 and sum(nums) / nb 

from statistics import mean

def find_average(nums):
    return mean(nums) if len(nums) > 0 else 0

def find_average(nums):
    sum = 0
    for num in nums:
       sum += num
    
    print(len(nums))
    try:
        avg = sum/len(nums)
    except:
        avg = sum
        
    return avg

def find_average(nums):
    if len(nums) == 0: return 0
    sum = 0
    for val in nums:
        sum += val
    return sum / len(nums)

def find_average(nums):
    x = sum(nums)
    y = len(nums)
    if y == 0:
        return 0
    return x / y

def find_average(nums):
    if nums == 0:
        return 0
    elif len(nums)==0:
        return 0
    else:
        return sum(nums)/len(nums)
    #your code here


def find_average(nums): 
    n = 0
    if nums == []:
        return n
        
    else:
        return sum(nums)/len(nums)


import statistics

def find_average(data):
    return statistics.mean(data) if data else 0

def find_average(nums):
    total = 0
    for i in range(len(nums)):
        total += nums[i]
    try:
        per = total / len(nums)
        return per
    except ZeroDivisionError:
        return 0

def find_average(nums):
    #your code here
    total = 0
    for num in nums:
        total += num
    return total / (len(nums) if len(nums) > 0 else 1)

def find_average(nums):
    sum = 0
    if not nums:
        return sum
    else:
        for num in nums:
            sum = sum +num
        average  = sum / len(nums)
        return average

def find_average(nums):
    if nums == []: 
        return 0
    sum = 0
    for i in range(len(nums)): 
        sum = sum + nums[i]
    return sum/len(nums)

def find_average(nums):
    total = 0
    for i in nums:
        total += i
    if nums:
        return total / len(nums)
    else: 
        return 0


def find_average(nums):
    sum = 0
    if len(nums) >0:
        for i in nums:
            sum += i
        return sum/len(nums)
    else:
        return 0

def find_average(nums):
    s = 0
    if nums == []:
        return 0
    else:
        for i in range(len(nums)):
            s = s + nums[i]
        return s/len(nums)

def find_average(nums):
    if len(nums) < 1:
        return 0
    else:
        return sum(nums) / len(nums)

import statistics
def find_average(nums):
    if len(nums)==0:
        return 0
    else:
        return statistics.mean(nums)

from numpy import mean
def find_average(nums):
    return mean(nums or 0)

def find_average(nums: list) -> float:
    return 0 if len(nums) == 0 else sum(nums) / len(nums)

from numpy import mean
def find_average(nums):
    return mean(nums) if nums != [] else 0

def find_average(nums):
    try:
        a = len(nums)
        b = sum(nums)
        c = b/a
    except:
        return 0
    return c

def find_average(nums):
    if len(nums) == 0:
        return 0
    sum=0
    for num in nums:
        sum+=num
    return sum/len(nums)

def find_average(nums):
    return sum(nums) / len(nums) if sum(nums) > 0 else 0

def find_average(nums):
    if len(nums) == 0 or nums == []:
        return 0
    else:
        return sum(nums)/len(nums)


from statistics import mean
def find_average(nums):
    if nums:
        return mean(nums)
    return 0

from statistics import mean
def find_average(nums):
    #your code here
    return mean(nums) if len(nums) != 0 else 0

def find_average(s):
    return sum(s)/len(s) if len(s)>0 else 0

def find_average(n):
    return sum(n)/len(n) if len(n)>0 else 0

def find_average(nums):
    a = sum(nums)
    return 0 if not nums else a / len(nums)

def find_average(nums):
    sum = 0
    for n in nums:
        sum += n
    if len(nums) == 0:
        return 0
    sum /= len(nums)
    return sum

def find_average(n):
    return sum(n)/len(n) if n else 0

import statistics
def find_average(nums):
    try:
        return statistics.mean(nums)
    except:
        return 0

def find_average(nums):
    sum = 0
    if len(nums) == 0:
        return 0
    else:
        for i in nums:
            sum += i
    return sum / len(nums)

def find_average(nums):
    try:
        accumulator = 0
        for eachnumber in nums:
            accumulator = accumulator + eachnumber
        return accumulator / len(nums)
    except ZeroDivisionError as zero_error:
        return 0

import statistics
def find_average(nums):
    if len(nums) > 0:
        return statistics.mean(nums)
    return 0

def find_average(nums):
    #your code here
    if len(nums)==0:
        return 0
    sums=sum(nums)
    avg=sums/len(nums)
    return avg

def find_average(nums):
    if nums == []:
        return 0
    else:
        x = 0
        for i in nums:
            x = i +x
        y = x / len(nums)

    return y

def find_average(nums):
    total = sum(nums)
    if len(nums) > 0:
        return total / len(nums)
    return 0

def find_average(nums):
    return nums and sum(nums)/len(nums) or 0

def find_average(nums):
    #your code here
    sum = 0
    for n in nums:
        sum += n
    if len(nums) == 0:
        avg = 0
    else:
        avg = sum / len(nums)
    return avg

import numpy as np
def find_average(nums):
    if len(nums) ==0: return 0
    return np.mean(nums)

def find_average(l):
    return sum(l) / len(l) if l else 0

def find_average(nums):
    sum = 0
    n = 0
    for i in nums:
        sum += i
        n += 1
    if n > 0:
        return sum / n
    else:
        return 0

def find_average(nums):
    tot = 0
    mean = 0
    
    if len(nums) == 0:
        return 0 
    
    for i, number in enumerate(nums):
        tot += number
    
    mean = tot/len(nums)  
    return mean
    #your code here


import numpy as np

def find_average(nums):
    return np.mean(nums) if len(nums) > 0 else 0

def find_average(nums):
    sum = 0
    if (len(nums) == 0):
        return 0
    for i in range(len(nums)):
        sum = sum + nums[i]
    return sum/len(nums)

def find_average(nums):
   return sum(nums)/len(nums) if len(nums)>=1 else 0

def find_average(nums):
    #your code here
    if nums == []: #or len(nums)==0:
        return 0
    else:
        b=len(nums)
        print(b)
        a=sum(nums)
        c=a/b
        return c


def find_average(nums):
    if len(nums) == 0:
        return 0

    total = 0
    
    for num in nums:
        total+= num
        
    return total/len(nums)

def find_average(nums):
    if len(nums) == 0:
        return 0
    s = sum(nums)
    n = s/len(nums)
    return n

def find_average(nums):
    if not nums:
        return 0
    else:
        return sum(nums)/len(nums)

def find_average(nums):
    average = 0
    sum_nums = 0
    count_nums = 0
    for num in nums:
        sum_nums += num
        count_nums += 1
        average = (sum_nums / count_nums)
    return average

def find_average(nums):
    try:
       return sum(nums)/len(nums)
    except (ZeroDivisionError):
       return False

def find_average(nums):
    if (not nums): return 0
    sum = 0
    quantity = 0
    for value in nums:
        sum = sum + value
        quantity += 1
    return sum/quantity


def find_average(nums):
    #your code here
    n = 0
    for n in nums:
        n = sum(nums)/len(nums)
    if len(nums) == 0:
        print('Error')
    else:
        print(n)
    return n


def find_average(nums):
    print(nums)
    #return [sum(nums)/len(nums) if len(nums)>0 else 0]
    items = 0
    total = 0.0
    for a in nums:
        items += 1
        total += a
    return 0 if items == 0 else total / items


def find_average(nums):
    return sum(i for i in nums)/len(nums) if nums!=[] else 0

def find_average(nums):
    try:
        return sum(nums)/len(nums)
    except ZeroDivisionError as ak:
        return 0


def find_average(nums):
    
    length = len(nums)
    if length == 0:
        return 0
    
    total = sum(nums)
    
    mean = total / length
    
    return mean

def find_average(nums):
    if len(nums) >= 1:
        return sum(nums) / len(nums)
    else:
        return 0

def find_average(nums):
    if len(nums):
        return sum(nums)/len(nums)
    return 0

def find_average(nums):
    if nums:
        average = sum(nums)/len(nums)
    else:
        average = 0
    return average

def find_average(nums):
    if len(nums) == 0:
        return 0
    else:
        total = sum(nums)
        avg = total / len(nums)
        return avg

def find_average(nums):
    if nums == []:
        return 0
    else:
        a=sum(nums)/len(nums)
        return a

def find_average(nums):
    if len(nums)==0:
        return 0
    a=0
    for i in nums: a+=i
    return a/len(nums)

def find_average(nums):
    #your code here
    if nums != []:
        return sum(nums)/len(nums)
    else:
        return 0