y = (website[-4:]!=".com" and website[-4:]!=".net" and website[-4:]!=".org" and website[-4:]!=".gov" and website[-4:]!=".edu")
website = str(input("Enter your URL: ")) protocol = "http://www." site = [".com" , ".net" , ".org" , ".gov" , ".edu"] y = (website[-4:]!=".com" and website[-4:]!=".net" and website[-4:]!=".org" and website[-4:]!=".gov" and website[-4:]!=".edu") # how to replace y with shorter condition if website[0:11] != protocol: print("invaild") elif website[0:11] == protocol: for i in site: if website[-4:]==i: print("http") print("www") print(website[11:-4]) print(website[-3:]) elif y == True: print("invaild") break
Quote:I want to write shorter condition than this Python y = (website[-4:]!=".com" and website[-4:]!=".net" and website[-4:]!=".org" and website[-4:]!=".gov" and website[-4:]!=".edu")
y = not (website[-4:] in site)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)