Create a Python program to take an array of numbers and calculate the average.
[1, 4, 5, 6, 7]
def average(nums):
    sum = 0
    for n in nums:
        sum += n
    return sum / len(nums)

nums = [1, 4, 5, 6, 7]
print(average(nums))