Problem 2. (Domain Type) Implement the function domain type) in domain_type.py t
ID: 3708466 • Letter: P
Question
Problem 2. (Domain Type) Implement the function domain type) in domain_type.py that returns the domain type of the URI specified as argument. For example, the domain type of the URL http://ww.svamiiyer. net/cs110/ is net. You may assume that the URL starts with 'http:// and ends with /". Hint: use the str methods find) and split s python domain.type py http:/w.swamiiyer.net/cs110/ net Linux Mint [Running] domain_type.py(/coursework/homeworks) File Edit View Search Tools Documents Help import stdio import sys # Returns the domain type of the given URL def domain_type(URL): # Test client [DO NOT EDIT]. Reads a URL as command-line argument and writes # its domain type. def main): URL = sys.argv [1] stdio.writeln(domain_type (URL)) if name la main main )Explanation / Answer
import sys def domain_type(URL): simple_url = URL.split('/')[2] return '.' + simple_url.split('.')[-1] print(domain_type(sys.argv[1]))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.