How to get domain name of email ID

0 votes

I am writing a script that will check the domain name and print the name of the domain. For example if the email id is abc@gmail.com, then the output should be Gmail and so on. How can I implement this?

Mar 28, 2019 in Python by shri
838 views

1 answer to this question.

0 votes

You can use the split method to split the string into two parts (before and after '@') and then compare it.

Hey, refer to the below code to do this:

email=’abc@gmail.com’

eid=email.split(‘@’)

if eid[1]==’gmail.com’:

    print “Gmail”
answered Mar 28, 2019 by Firoz

Related Questions In Python

0 votes
1 answer

How can I get the domain name of my site within a Django template?

Hello kartik, The variation of the context processor ...READ MORE

answered Apr 23, 2020 in Python by Niroj
• 82,880 points
9,305 views
+1 vote
1 answer

How to replace id with attribute corresponding to id of another table?

Use the following query statement and let ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 58,090 points
1,997 views
0 votes
1 answer

How to get the size of a string in Python?

If you are talking about the length ...READ MORE

answered Jun 4, 2018 in Python by aryya
• 7,450 points
1,053 views
0 votes
0 answers

how to get mongoengine object id in flask program

i am using mongoengine to integrate with ...READ MORE

Oct 5, 2018 in Python by eatcodesleeprepeat
• 4,710 points
5,976 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,007 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,386 views
0 votes
1 answer

How to get a Mongoengine's object id in a flask program

Check out the documentation, Document.objects is a QuerySet object. You seem to be ...READ MORE

answered Sep 21, 2018 in Python by charlie_brown
• 7,720 points
2,777 views
0 votes
1 answer

How to replace id with attribute corresponding to id of another table?

Try looking the given link for better ...READ MORE

answered Oct 3, 2018 in Python by Priyaj
• 58,090 points
433 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP