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

Decorator Introduction
A decorator takes in a function, adds some functionality and returns it. Functions can be passed as arguments to another function like map, filter and reduce Function that take other functions as arguments...

What is a generator?
A generator is a function that has one or more yield statements. Example: >>>def gen_demo(a): yield a a = a+10 yield a a = a+30 yield a >>>gen_a...

Python SubProcess
Question: As a Network Administrator, one of my trainee wants to know the below: He has certain number of Machines(IP’s). On daily basic he wants to know how many IP’s are reachable and...

Python- 5 reasons to learn python
1. Dynamically Typed You don’t have to declare a type when declaring a variable. It skips headaches of type casting JAVA:- int x = 1; x = (int) x/2;...

10 Best Python IDEs
Python is a very popular programming language. It's open source and used today as scripting language, web development, mobile and desktop in many areas thanks to the endless modules options it has While...
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