I'm currently struggling to separate a string into two while using a white space as the base of the split.
I'm writing a program where a person is supposed to input their first and last name as a string. Then the program should take the first three letters out of the first name and first three letters out of the last name. Put these together and append them to a domain name creating an email. Such as Firstname Lastname becomes firlas@example.com. I know I could easily solve the problem by just using two inputs, but I want it to be only one input.
def create_email_address():
name = input("Please input your first and last name: ")
domain = "@aperturescience.com"
email_address = str.lower(name[:3]) + str.lower(name[10:13]) + domain
print(str(email_address))
This is what I have so far, and while I have experimented using list splits and indexes I can't get it to work properly. I can get the index to work when I use my own name as an example name. But if I input something that doesn't have the same amount of characters in it it doesn't perform as I want it to.
What I would like is to separate the first name and last name using the white space as the indicator where the split is supposed to be. That way it won't matter how long or short the names are, I can always index after the first three letters in each name.
Is this possible? and if so, any tips?
Thanks!