When you are not sure how to approach a problem, I suggest starting with some documentation. For example, you can check out the string methods and common string operations.
Scrolling through this list, you will read about the find() function:
Return the lowest index in the string where substring sub is found within the slice s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found.
So to find the "?" you can do this:
i = url.find("?")
Rather than thinking about how to remove part of the string, let's figure out how to keep the part we want. We can do this with a slice:
url = url[:i]
url.split('?')[0]