Q:

A function that recieves three numbers and a list, gets an average of those three numbers and subtracts the average from each number on the list

I've got a question regarding how to improve something small I wrote. I'm fairly new to Python and I tried to make this with a for loop but failed, I was wondering if there was a more efficient way to write this function(I wanted to do it with a for loop but if u guys have a better idea I'd appreciate if you posted it). Thanks! 
Btw, the list recieved is only numbers, there aren't any strings, chars, etc.
def newList(n1,n2,n3,List):
    avg = (n1+n2+n3)/3
    i=0
    while i<len(List):
        List[i] -= avg
        i += 1
    print D

A:

Python’s list comprehensions are useful when you want to perform the same operation on every item in a list. For example, suppose you had a list of numbers defined as follows:
list_of_numbers = [1, 2, 3, 4, 5]

To add 5 to every number in this list and put it into a variable called new_list, you’d use a list comprehension:
new_list = [number + 5 for number in list_of_numbers]

If you check the value of new_list, you’ll see it is:
[6, 7, 8, 9, 10]

You can use a list comprehension in your newList() method:
def newList(n1, n2, n3, list):
  average = (n1 + n2 + n3) / 3
  result_list = [item - average for item in list]
  return result_list

When you call it like so:
newList(1, 2, 3, [4, 5, 6])

you’ll get this result:
[2, 3, 4]

