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.