Project Description
Your task today is to build a Python program that checks if an email address is valid — using regular expressions (regex). This isn’t just a theoretical exercise: validating email formats is a real-world necessity for login systems, signup forms, newsletter signups, admin dashboards, and more.
Here’s the challenge:
Ask the user to input an email address.
Use a regular expression to validate if it has the correct format (like
someone@example.com
).Print whether it’s valid or not.
And for those ready for an extra challenge:
💡 Turn this into a small graphical app using tkinter
, so users can paste an email and press a button to validate it.
This project gives you practice with:
re.match()
from Python’sre
moduleReal-world string patterns and data validation
Optional: building a tiny GUI with
tkinter
Expected Output
Or:
💡 Hint
Need help getting started with regex? Click the button below to learn how to define a pattern and test user input.
𝌣 Solution
🔒 This solution is available to paid subscribers only.
🧠 You'll find both a terminal-based solution and a version with a GUI interface.
🚀 Want to keep leveling up?
Browse 200+ projects at dailypythonprojects.substack.com/archive and unlock all solutions by subscribing. Build real Python skills daily and transform how you learn — one project at a time.
I've put together a basic version, here is my script:
import re
def validate_email(email):
pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2, 6}$"
if re.match(pattern, email):
return True
else:
return False
email = input("Enter an email to check if it's valid: ")
if validate_email(email):
print("✅ That's a valid email address!")
else:
print("❌ That's not a valid email address.")