DEV Community

Cover image for Welcome | Rookie Week of Python Day 01
Hannan
Hannan

Posted on

Welcome | Rookie Week of Python Day 01

Python. The first and last love of most newbie programmers. Love it or hate it (does anyone really?) almost everyone has been drawn to it at one time or another. Recently I have started coding in python once again, and if like me, you too are a bit more than a little rusty at it, or maybe just hungover from the move to Python 3 from Python 2 in your time away from the language, this series of beginner level python projects is for you. Yes, I am bringing you a week straight of python projects, in varying difficulty levels, from around the web (I, in no way claim that these are the most original idea). Follow along and get back on the horse.
For Day 1 we will be creating a very simple Email splitter program.

Email Splitter

The concepts we will use in it are strings, strip() functions, and basic input methods. Easy enough right?
We will start with a very basic variable input and use a strip() function to split it.

email = input("Enter Email:").strip()

Next we will declare two variables, each to hold the username and the domain name respectively. We will be splitting the string at the '@' like so.

userName = email[:email.index("@")]
domainName = email[email.index("@")+1:]

Now that we have our two values stored in separate variables, we need to be able to use them independently, In this case, being able to print them.

output = "Username: '{}' Domain Name: '{}'".format(userName,domainName)

If you want the code used here you can also check it out on my GitHub repository here. feel free to make it more complex.
Now that you have started your first project, stay tuned for more tomorrow.

Top comments (0)