How to Remove Query String from URL in Python

While working on our latest project we needed to remove the query string from a URL. And store it in the database. Here how I did it in Python.

def query_string_remove(url):
    return url[:url.find('?')]

Make sure you are giving valid URL.

Valid -“Hello

Invalid -“Hello”