Create a function in Python that takes an array of integers and returns an array of their squares.
[1, 2, 3]
def square_array(nums): 
    return [n**2 for n in nums] 

result = square_array([1, 2, 3])
print(result)