RESTRICTIONS, PLEASE READ: Do not add any imports, the ones that you need will be given to you. Do not use try-except statements, you should be able to anticipate or prevent any errors from happening at all! """ import re def find_email(s: str) -> str: """ Given a string , return the email that exists in the string. Preconditions: contains at most 1 email, or none at all. If does not contain an email, return the empty string. Email definition: An email address is defined as 'name@domain.com' or 'name@domain.ca' with the following specifications: name: the name is an alphanumeric string that is less than or equal to 12 characters. Additional characters allowed are dash (-), period (.) and underscore (_). But the email cannot start or end with these additional characters. The name must also be at least 1 character long. Example names: a ab a_b A__B..C--D 1nt3r3st.1ng domain: the domain is strictly numerical, and the number must be divisible by 5. the length of the domain is unrestricted. Example domains: 984125 0 ending: the email must end with a (.com) or (.ca) (case sensitive) Note: you must not use any loops (for, while) here. Just use the re library for this function. >>> find_email('12345a_test_email@165265365.com!') 'a_test_email@165265365.com'

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

RESTRICTIONS, PLEASE READ:
Do not add any imports, the ones that you need will be given to you.
Do not use try-except statements, you should be able to anticipate
or prevent any errors from happening at all!
"""

import re


def find_email(s: str) -> str:
"""
Given a string <s>, return the email that exists in the string.

Preconditions:
<s> contains at most 1 email, or none at all.

If <s> does not contain an email, return the empty string.

Email definition:
An email address is defined as 'name@domain.com' or 'name@domain.ca'
with the following specifications:

name: the name is an alphanumeric string that is less than or
equal to 12 characters. Additional characters allowed are
dash (-), period (.) and underscore (_). But the email
cannot start or end with these additional characters.
The name must also be at least 1 character long.
Example names:
a
ab
a_b
A__B..C--D
1nt3r3st.1ng

domain: the domain is strictly numerical, and the number must be
divisible by 5. the length of the domain is unrestricted.
Example domains:
984125
0

ending: the email must end with a (.com) or (.ca) (case sensitive)

Note: you must not use any loops (for, while) here.
Just use the re library for this function.

>>> find_email('12345a_test_email@165265365.com!')
'a_test_email@165265365.com'
"""

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY