Edit the following Python function to raise an exception if the given number is lower than 0.
def square(num):
    return num**2
def square(num):
    if num < 0:
        raise ValueError('Cannot square negative numbers.')
    return num**2