...
Code Block |
---|
import re def test_email(your_pattern): pattern = re.compile(your_pattern) emails = ["john@example.com", "python-list@python.org", "wha.t.`1an?ug{}ly@email.com"] for email in emails: if not re.match(pattern, email): print("You failed to match %s" % (email)) elif not your_pattern: print("Forgot to enter a pattern!") else: print("Pass") pattern = r"[a-z0-9]+@[a-z0-9]+\.[a-z0-9]+" test_email(pattern) |
Exception Handling - try/except block
Info |
---|
def do_stuff_with_number(n): def catch_this(): for i in range(20): catch_this() |