Question: To practice slicing and using string methods An email address is a sequence of characters with the following structure: it contains exactly one @ character
To practice slicing and using string methods
An email address is a sequence of characters with the following structure:
it contains exactly one @ character
there are or more characters before the @ We call these characters the username
There is at least one period SOMEWHERE after the @
IMMEDIATELY after the @ there are one or more characters that are NOT periods. We call all the
characters after the @ the fully qualified domain name FQD within the FQD there are zero or more
subdomains separated by periods, a domain before the lastperiodafterthe@ and a toplevel do
main ie com, ca etc after the last period.
For this question, you will write a program that lets the user type in a valid email address, and reports the
username and the toplevel domain components of that address. Your program may assume that the
user always types a correctlyformatted email address. You may also assume all toplevel domains are no
longer than characters.
Hint: Tools such as slicing, negative indexing, and the string method find will probably be the most
useful here.
Sample Runs
Here is one possible sample run. Green text was entered by the user, and the blue text is based on that
input.
Enter email address : ash@pokemon.kanto.jp
Username : ash
First Subdomain Domain : jp
Here is another one.
Enter email address : jeff.long@usask.ca
Username : jeff.long
First Subdomain Domain : ca
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
