0 out of 464 challenges solved
Write a Python function `nth_power(nums, n)` that takes a list of numbers `nums` and an integer `n`, and returns a new list where each number in `nums` is raised to the power of `n`. #### Example Usage ```python [main.nopy] print(nth_power([1, 2, 3, 4], 2)) # Output: [1, 4, 9, 16] print(nth_power([2, 3, 4], 3)) # Output: [8, 27, 64] print(nth_power([5, 10], 0)) # Output: [1, 1] ``` #### Constraints - The input list `nums` will contain integers. - The integer `n` can be positive, negative, or zero.
def nth_power(nums, n): """ Compute the n-th power of each number in the list. Args: nums (list): A list of integers. n (int): The power to which each number should be raised. Returns: list: A list of integers where each element is raised to the n-th power. """ # Replace the following line with your implementation pass