Question

Write a program in python that checks if an email is valid or not by checking...

Write a program in python that checks if an email is valid or not by checking if there is an ‘@’ and ‘.’ in the provided string. Declare 3 variables that include 3 different emails, pass these variables as an argument to a function, and the function should return whether the email is valid or not.
Example,
email1 = “hello.edu” à INVALID
email2 = “hello@sju.edu” à VALID
email3 = “my email address is: email@sju.edu” à VALID

Tip,
In order to check if a string contains a character, we can use in keyword in a conditional statement. See below:

>>> email = ‘hello@sju.edu’
>>> if "@" in email and "." in email: ... print(email, "valid")
>>> else:

print(email, "invalid")

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def checkEmail(email):
    if "@" in email and "." in email:
        print(email, "valid")
    else:
        print(email, "invalid")

# Testing
email1 = "hello.edu"
email2 = "hello@sju.edu"
email3 = "my email address is: email@sju.edu"
checkEmail(email1)
checkEmail(email2)
checkEmail(email3)

Add a comment
Know the answer?
Add Answer to:
Write a program in python that checks if an email is valid or not by checking...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment 14.3: Valid Email (10 pts) image source Write a program that takes as input an...

    Assignment 14.3: Valid Email (10 pts) image source Write a program that takes as input an email address, and reports to the user whether or not the email address is valid. For the purposes of this assignment, we will consider a valid email address to be one that contains an @ symbol The program must allow the user to input as many email addresses as desired until the user enters "q" to quit. For each email entered, the program should...

  • Write a python program that contains a hardcoded string and checks whether it is a palindrome...

    Write a python program that contains a hardcoded string and checks whether it is a palindrome (the same forwards as backwards). If it is then display “It is a palindrome”, otherwise display “It is not a palindrome”. A hardcoded string is simply a string defined in your program, for example: my_string = “Hello” Some sample palindromes to use are: A car, a man, a maraca Desserts, I stressed Madam, I’m Adam You will need to strip out any punctuation such...

  • 8.4 in python function that checks whether a string is a valid password. Suppose the pas...

    8.4 in python function that checks whether a string is a valid password. Suppose the pas rules are as follows: . A password must have at least eight characters - A password must consist of only letters and digits. ■ A password must contain at least two digits. Write a program that prompts the user to enter a password and displays valid password if the rules are followed or invalid password otherwise (Occurrences of a specified character) Write a function...

  • Write a program with a function that accepts a string as an argument and returns a...

    Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character of each sentence capitalized. For instance, if the argument is “hello. my name is Joe. what is your name?” the function should return the string “Hello. My name is Joe. What is your name?” The program should let the user enter a string and then pass it to the function. The modified string should be displayed.

  • please type code in Python find all the VALID email address in this input text file...

    please type code in Python find all the VALID email address in this input text file and store them as a single column of valid email addresses in an output text file labeled OutputFile First cut/paste the block of text below into a separate text file and label that data file InputFile: FinancialAid Email: finaid@myschool.edu Scholarships Financial Aid Phone: 979-555-3236 Email: random@ubx.net Financial visit@tamu.com Aid helpdesk@tamu.notvalid Help Desk Central fakename@egr.msu.org Dean's Office      Jill Educational Program Coordinator II    Create...

  • Please help me write down a program to check email address valid or not. Tip:parse the...

    Please help me write down a program to check email address valid or not. Tip:parse the string and count the special characters like '@', '.' .and at least one character. Suggested libc functions: printf() 1.Have to be by the argc/argv of main function 2.Connot use scanf/getchar and other user input functions 3.Please explain the details and steps for me cause I'm a beginner hhhhhh Thank you soooo much for helping me!

  • Write a program(JAVATPOINT) to validate email addresses. Use a loop to go over each character, and...

    Write a program(JAVATPOINT) to validate email addresses. Use a loop to go over each character, and find an @ sign, followed by two or more words separated by dots. Examples of valid emails are moeki@vanier.college and moeki@vaniercollege.qc.ca, and invalid ones would be moeki&vanier.college or moeki@vanier.

  • Write a program IN PYTHON that checks the spelling of all words in a file. It...

    Write a program IN PYTHON that checks the spelling of all words in a file. It should read each word of a file and check whether it is contained in a word list. A word list available below, called words.txt. The program should print out all words that it cannot find in the word list. Requirements Your program should implement the follow functions: main() The main function should prompt the user for a path to the dictionary file and a...

  • please use Python You are to create a program that generates an email addresses. The format...

    please use Python You are to create a program that generates an email addresses. The format is as follows: firstname.lastname@domain.topleveldomain (maximum 60 characters) example (aaa.bbb@ccc.ddd) please use any number of variables and types that you wish. The only requirement is that you ask the user one at a time for first name, last name, domain and TLD (top level domain), use that to generate the email address string. The maximum size of the created email address string is 60. If...

  • Here is the UML for the class Contact -fullName : string -phoneNum: string -emailAddress : string...

    Here is the UML for the class Contact -fullName : string -phoneNum: string -emailAddress : string +Contact()                     //default constructor sets all attribute strings to “unknown”; no other constructor +setName(string name) : void +setPhone(string pn) : void +setEmail(string em) : void +getName() : string +getPhone() : string +getEmail() : string +printContact() : void         //print out the name, phone numbers and email address Create New Project Name your project: CIS247_Lab7_YourLastName. For this exercise, you may use a header file or one file...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT