This is a python programme to check the domain name of website,i am getting an ouput like this…but the expected output must be like “commercial domain”.
what is the error in this code
@dsedyoda
mam, for the same code which used for checking the email domain its working fine and i’m getting the right output…for checking website domain the answer gone wrong…
For checking website domain we have to change our approach because we have more than one dots (.) In the website name. And as I know here finditer is not checking for dot (.).
Please use different approach for website domain name checking because for loop will iterate to full length when match will be dot (.).
I am giving you one example for one approach
import re
commercial_pattern = r’^www.[a-zA-Z0-9-]{1,63}.com$’
org_pattern = r’^www.[a-zA-Z0-9-]{1,63}.org$’
website to check
website = ‘www.example.com’
if re.match(commercial_pattern, website):
print(f"{website} is a commercial website")
elif re.match(org_pattern, website):
print(f"{website} is an organizational website")
else:
print(f"{website} is neither a commercial nor an organizational website")