Question

In: Computer Science

I am confused with Python I have to write a specification for an email address. In...

I am confused with Python I have to write a specification for an email address. In one string a valid email address and the other without a valid email address.

Ex:

print(text_match("My teacher’s email is [email protected]"))

print(text_match("My teacher has no email address"))

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. We need to use the re (Regular Expression) module to check if the email satisfies the email format. Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

import re

def text_match(email):
    regex = '^.+[@]\w+[.]\w{2,3}$'
    pattern = re.compile(regex)
    if (pattern.search(email)):
        return 'Valid'
    else:
        return 'Invalid'


print(text_match("My teacher’s email is [email protected]"))
print(text_match("My teacher has no email address"))

======================================================================


Related Solutions

I have the problem in bold below. I am completely confused. I am hoping that I...
I have the problem in bold below. I am completely confused. I am hoping that I will see how you did this and will be able to follow it. Please remember that I have just started this so please don't use any complex features that an absolute beginner (like me) wouldn't know. Additional information:   /*This is what everyone owes before tax and tip:     Person 1: $10     Person 2: $12     Person 3: $9     Person 4: $8     Person 5: $7     Person 6:...
I have a question about C++ programming Language class. I am confused with these terms and...
I have a question about C++ programming Language class. I am confused with these terms and what they are for. 1. Unix 2. Terminal 3. Git 4. CLOC 5. Linux Please explain each words and what's their jobs for C++. Also, if you know some good sources/websites, could you please provide me a link where I can learn how to use Unix, Terminal, Git, etc.
I am getting confused on finding the ethical challanges to this question. I am understanding but...
I am getting confused on finding the ethical challanges to this question. I am understanding but second guessing my answers when it come to the elements and the Ethical Code Standards. 1. Identify an ethical challenge for each element (a-d) of Dr Lux advertising plan. Which General Principles and Ethical Code Standards best help understand why these elements may create ethical problems? Explain why. Case 5. Web-Based Advertising. Dr. Lux, an applied developmental psycholgoist, has created his own community consulation...
Hello, I am studying and I am a bit confused about registers. There are segments registers,...
Hello, I am studying and I am a bit confused about registers. There are segments registers, data registers, pointer registers, index registers. But I do not really understand where these are found. Are they found in 8086 architecture? For instance if I ask what type of registers are found in 8086 architecture what will be the answer? All of these or only segment registers?
How to organize this email: I am writing this email to let you know that we...
How to organize this email: I am writing this email to let you know that we have been working hard to plan the Gamma Fall Training Conference. It will be held in Miami. Here are the speakers I have lined up for training sessions. I'm thinking that on Tuesday, November 12, we will have Nicole Gold. Her scheduled topic is "Using E-Mail and IM Effectively." Anthony Mills said he could speak to our group on November 13 (Wednesday). "Leading Groups...
Hi I am working on my chemistry homework about acids and bases and I am confused...
Hi I am working on my chemistry homework about acids and bases and I am confused on this question from a lab. We used grape juice and cranberry juice and we had to put HCl and NaOH in the test tube full of juice. 1. Referring back to procedure 1 of the experiment, which of the two juices is more useful as a general pH indicator and why? I think it is grape juice but I just don't know what...
This is to be done in excel (which I can do), but I am confused about...
This is to be done in excel (which I can do), but I am confused about which tail test to use and why to accept or reject H0- and the summary. According to research, holiday shoppers spent an average of $370 over a holiday weekend in 2008. The accompanying data show the amount spent by a random sample of holiday shoppers during the same weekend in 2009. Retailers were concerned that the economic downturn was affected holiday sales. Does this...
I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
We must have a random sample when investigating the confidence interval of µ. I am confused...
We must have a random sample when investigating the confidence interval of µ. I am confused by this question. Is this true or false and why.
This is my lab and I am very confused regarding the calculations! It is supposes to...
This is my lab and I am very confused regarding the calculations! It is supposes to demonstrate Le Chatelier’s principle. After doing the following I need to calculate the molar absorbance for Co(H20)6 2+. The path length is 1cm and absorbance is .551. I got 5.51 L/mol *cm. I also need to calculate the CoCl4 2- molar absorbance which I do not understand. The absorbance is .570 and the path length is 1cm. I do not know how to find...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT