use
ext = filename.split(".")[-1]