livepython.net

104. Python Program to Check a Simple Email Address

MediumMethods

Overview

Clean up text, then test it with several string methods joined by and.

Problem Statement

Read an email address. First clean it up: remove the spaces at both ends and make every letter small, then print it. On the next line, print Valid email if all of these are true, and Invalid email if any of them is false:

  • it has exactly one @
  • it does not start with @
  • it ends with .com
  • it has no space in it

For example, for Sunny@Example.COM:

sunny@example.com
Valid email

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One line with an email address. Example:

Sunny@Example.COM

Output

The output for that example:

sunny@example.com
Valid email

The tests try 6 different inputs, one for each rule.

Learn this firstChapter 12 · Python String Methods: upper, strip, replace, find
solution.py
# write your code here

EXPECTED OUTPUT

1sunny@example.com
2Valid email

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.