Question

Hello, In Python, I am trying to create a function that will return the domain name...

Hello,

In Python, I am trying to create a function that will return the domain name from any inputted email address. For example, my input of [email protected] would return just the domainname. It needs to be done using regular expressions and the map function. I'm still stuck on trying to get the correct parameters for regular expression and also what is throwing it off. Thank you for your help!

I am currently working with a list of different email addresses named email_list and my code thus far looks like:

def domain(email):
a = re.findall('\S+@\S+', email_list)
return(a)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import re #imports library
print("enter your email") # it's a print statement will be displayed as is on console
s = input() #takes input
domain = re.search("@[\w.]+", s) #splits out domain from email after @
print domain.group() #prints domain of the email.

Add a comment
Know the answer?
Add Answer to:
Hello, In Python, I am trying to create a function that will return the domain name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hi I'm trying to write a code for a web server in python with flask. This...

    Hi I'm trying to write a code for a web server in python with flask. This is what I have so far from flask import Flask app = Flask(__name__) @app.route('/') #first endpoint i.e. "http://localhost/" def index(): return 'hello' #return data in string if __name__ == '__main__': app.run(debug=True) After running the code, I'm given a address to the web with the text hello. The problem is that this only works with my computer that is running the code. If I try...

  • python beginner question! Hello, i am trying to allign the two variable below next to each...

    python beginner question! Hello, i am trying to allign the two variable below next to each other using a for loop, like this table below: 1 3 2 7 3 1 4 2 5 0 heres the code I use: balls = [1,2,3,4,5] count = [3,7,1,2,0] for j in numbers: print("{:}".format(j)) for i in count: print('{:10}'.format(i)) but the output looks like this: 1 2 3 4 5 3 7 1 2 0 i need my output to look like the...

  • Python Problem Hello i am trying to finish this code it does not save guesses or...

    Python Problem Hello i am trying to finish this code it does not save guesses or count wrong guesses. When printing hman it needs to only show _ and letters together. For example if the word is amazing and guess=a it must print a_a_ _ _ _ not a_ _ _ _ and _a_ _ _ separately or with spaces. The guess has a maximum of 8 wrong guesses so for every wrong guess the game must count it if...

  • Hello. I want to write a function in C program to track calories for specified fitness activities...

    Hello. I want to write a function in C program to track calories for specified fitness activities i.e. run, walk, bike etc. I am trying to make an array with the activities and return calories burned per minute for each workout. The function will keep running until user tells it to stop. "maybe 'while' loop (Y/N)" or something like that. The main function will call the activity function and a few printf/scanf. My code looks pretty bad so if you...

  • I am using Python 3.5.2 2. Create a function called is_interesting that, given a string, returns...

    I am using Python 3.5.2 2. Create a function called is_interesting that, given a string, returns the Boolean value True if the number of vowels (a e i o u) in the string is a prime number (assume that the strings are always passed as lower-case letters to simplify). The function header should be as follows: def is_interesting(a_string) For example is_interesting(“yien”) returns True, is_interesting(“wang”) returns False

  • In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as...

    In python, PART A: I am trying to get a dictionary with size(4, 5, 6) as keys and an array for key containing a list of values (words from file of respective size) associated with those keys I am reading from a file of strings, where I am only interested with words of length 4, 5, and 6 to compute my program reading the text file line by line: At first, I have an empty dictionary then to that I...

  • Hello everyone! I am working on my assignment for C++ and I'm having a bit of...

    Hello everyone! I am working on my assignment for C++ and I'm having a bit of trouble on the value producing functions, I am creating a program wherein I have to input a value and I need to create a function called square value where in it will square the value I have input. I cannot seem to figure out this part. Here is the code that I have so far, and thank you for any help. I greatly appreciate...

  • I am having a little trouble with my Python3 code today, I am not sure what...

    I am having a little trouble with my Python3 code today, I am not sure what I am doing wrong. Here are the instructions: and here is my code: update: I have seen I did not close x in sumFile and I am still only getting a 2/10 on the grader. any help appreciated. Lab-8 For today's lab you going to write six functions. Each function will perform reading and/or write to a file Note: In zybooks much like on...

  • Hello, I am having trouble with a problem in my C language class. I am trying...

    Hello, I am having trouble with a problem in my C language class. I am trying to make a program with the following requirements: 1. Use #define to define MAX_SIZE1 as 20, and MAX_SIZE2 as 10 2. Use typedef to define the following struct type: struct {     char name[MAX_SIZE1];     int scores[MAX_SIZE2]; } 3. The program accepts from the command line an integer n (<= 30) as the number of students in the class. You may assume that the...

  • I am trying to create a ATM style bank program that accept the customer id ,...

    I am trying to create a ATM style bank program that accept the customer id , in the welcoming panel ,but how do i make when the customer input their id# and click on the ok button then they have 3 or so tries to input the correct id# and if successful then send to the other panel where they choose which transaction to they want to make for example savings , checking account , make and deposit , and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT