def extension(filename):
    """ returns the extension when given a filename

    will return None if there is no extension

    >>> extension('foo.bar')
    'bar'
    >>> extension('foo')
    None
    """
    s = filename.split('.')
    if len(s) > 1:
        return s[-1]
    else:
        return None