logo

Remove anchor from URL

Complete the function/method so that it returns the url with anything after the anchor (#) removed.


My code:


def remove_url_anchor(url):
    new_url = []
    for char in url:
        if char != "#":
            new_url.append(char)
        else:
            break
    result = "".join(new_url)
    return result
                    


And that's the best solution among all users:


def remove_url_anchor(url):
  return url.split('#')[0]