Answer:
Python Code:
def validate_url(url):
#Creating the list of valid protocols and file name extensions
valid_protocols = ['http', 'https', 'ftp']
valid_fileinfo = ['.html', '.csv', '.docx']
#splitting the url into two parts
url_split = url.split('://')
isProtocolValid = False
isFileValid = False
#iterating over the valid protocols and file names for validity
for x in valid_protocols:
if x in url_split[0]:
isProtocolValid = True
break
for x in valid_fileinfo:
if x in url_split[1]:
isFileValid = True
break
#Returning the result if the URL has both valid protocol and file extension
return (isProtocolValid and isFileValid)
url = input("Enter an URL: ")
print(validate_url(url))
Explanation:
The image of the output code is attached. Hope it helps.