How to get domain name and why my code using strip method doesn't work?

Hello,

I have a task of writing a code that will return only a domain name (for example codeacademy.com) and I tried with using strip method but it seems to work only partially. It removes the part on the left of the domain name, but not on the right as well. Here’s my code:

url = input("Unesite url: ")
url = url.strip("https://")
url = url.strip("http://")
url = url.strip("/")
print(url)

The urls I need to shorten only to a domain name all have either https:// or http:// on the left and after .com they all start with /, or finish there, so that’s why I tried using these 3 strips.

Thank you.

Is there definitely a trailing forward slash at the end of the input value e.g. https://codecademy.com/?

Thank you for your answer, I’ll reply as soon as I find some more time, I’m writing this from work, just entered to check if someone answered. : )

You’re right, I don’t know what I was thinking, the slash is only the first thing there is after .com, but definitely not at the end.