In this article, you will see how to check if a string is an email in Python. An email string is a string that contains an email address with the @ sign. We can use count() along with this
strip() method to check if a string contains an @ sign.
Step 1: Create a string
str = "email@example.com" print("str = ", str) print("str type = ", type(str))
Step 2: Check if string is a email
if str.strip().count("@") == 1: print("Email") else: print("Not Email")
str = firstname.lastname@example.org str type = <class 'str'> Email