Q:

Python passing list into a function and return back to main

I am taking 3 values from the users. Number1, Number2 and Power, considering Number1 and Number2 as a range of a list. Then I am trying to pass the list of the of numbers into a function as a parameter along with the power value as another parameter. Using the pow function to calculate the powers of each of the numbers in the list using a for loop. I want to store the results in the same list which was passed into this function and return back to the main function and print there. Now the question is, I assume i am trying the wrong approach since the output is not as expected. I declared another list (results) and store all the power results from the numbers list into it. Then asigned the results list to numbers list, so as to copy all the values in it. Now when i return the numbers list and print in the main function, it still shows the same values which were in the numbers list before it was sent to the function. Though when i try to print the list inside the function, it gives correct output. How am I wrong, and how should i correct it?
def powerList(numbers, power):
   print("In the function")
   print(numbers)
   print("Calculating powers")

   result = []
   for x in range(len(numbers)):
      result.append(pow(numbers[x], power))

   numbers = result
   return(numbers)

def main():
   n1 = int(input("Input number1: "))
   n2 = int(input("Input number2: "))
   power =  int(input("Input power: "))
   numbers = [x for x in range(n1,n2+1)]
   print(numbers)
   print("Passed to the function powerList")
   powerList(numbers, power)
   print(numbers)

main() 

A:

Try getting the returned object:
numbers = powerList(numbers, power)

Another thing that you can do is return the function output directly without saving it to another variable:
return powerList(numbers, power)

A:

If you want the function to mutate the argument list, do so explicitly and (by convention) return None, e.g.:
def power_list(numbers, power):  # note PEP-8 naming style
    for index, item in enumerate(numbers):
        numbers[index] = pow(item, power)
    # no explicit return is equivalent to 'return None'

which replaces the content of numbers one element at a time, or:
def power_list(numbers, power):
    numbers[:] = [pow(number, power) for number in numbers]

which uses a list comprehension to create a new list, then overwrites the content of the original with the new values. In use, with either version:
>>> lst = range(5)
>>> lst
[0, 1, 2, 3, 4]
>>> power_list(lst, 2)
>>> lst
[0, 1, 4, 9, 16]

