UrbanPro
true

Learn Python Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Learn Python : Slicing out an email address

B
Biswanath Banerjee
12/04/2018 0 0

We take a small task of slicing out the username and domain name from an email address. We ask the user to type his email address. We take his email address and slice out first his username and then the domain name of the user. Then we display his username and the domain name after formatting the message.This small program can be written in Python very easily. Lets python this task below:

#get user email address
email = input("what is your email address? ").strip()

#slice out username
user =email[:email.index("@")]

#slice out the domain name
domain = email[email.index("@")+1:]

#format message
output = "Your username is {}and your domain name is {}".format(user,domain)

#display output message
print(output)

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

The Zen of Python
Writing programs that actually do what they are supposed to do is just one component of being a good python programmer. It's also important to write clean code that is easily understood, even weeks after...

Python Programming or R- Programming
Most of the students usually ask me this question before they join the classes, whether to go with Python or R. Here is my short analysis on this very common topic. If you have interest/or having a job...

Decorators In Python
A decorator takes in a function, adds some functionality and returns it. Functions and methods are called callable as they can be called. Any object which implements the special method __call__() is...

Back Reference In Python Regex
What if your interviewer asks about this? We know Regex have some useful functions like: match ( Ex: re.match(pattern,dataSource) ) search ( Ex: re.search(pattern,dataSource) ) sub ...

Python breaks into the top three programming languages in the Tiobe Index for the first time.
Python breaks into the top three programming languages in the Tiobe Index for the first time. The popularity of Python shows no sign of waning, with the programming language entering the top three in...
X

Looking for Python Training Classes?

The best tutors for Python Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Python Training with the Best Tutors

The best Tutors for Python Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more