Write a Python code snippet to obtain the average of the elements in a given list.
list = [2, 3, 5, 4]
def average(list):
 total = 0
 for num in list:
 total += num
 return total / len(list)

print(average([2, 3, 5, 4]))