3.7. Sampled Average 2

Write a function named sampled_average that takes a list of integers and an integer as a target average. This function return “yes” if we can remove a single element from the given list so that the average of the remaining is equal to target average, prints “no” otherwise.

Sample I/O:

Sample input and output:

>>> sampled_average([1,2,3,10], 2)
'yes'

>>> sampled_average([1,3], 2)
'no'
def sampled_average(numbers, k):
    n = len(numbers)
    if sum(numbers) - k * (n - 1) in numbers:
        return "yes"
    else:
        return "no"