Skip to content

Instantly share code, notes, and snippets.

@TomColBee
Created June 6, 2018 18:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TomColBee/4cf607f2e5b0e7b703b4d343d6a6c4e8 to your computer and use it in GitHub Desktop.
Save TomColBee/4cf607f2e5b0e7b703b4d343d6a6c4e8 to your computer and use it in GitHub Desktop.
Python Bible: Email Slicer - String Index, Format and Print
# Get user email address
email = input("What is your email address?: ").strip()
# Slice out the user name
user_name = email[:email.index("@")]
# Slice the domain name
domain_name = email[email.index("@")+1:]
# Format message
output = "Your username is '{}' and your domain name is '{}'".format(user_name,domain_name)
# Display output message
print(output)
@Lord-Shax
Copy link

import re
def recog():
x = input('enter name and email: ')
match = re.search(r'@[\w-]+', x)
email = match.group(0)
e = email[1:]
print('Oh nice, I see your mail is a', e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment