Here’s some “python magic”
name = ['Elon Reeve Musk']
f"{''.join(filter(str.isupper, name[0]))}@company.com".lower()
>>> [email protected]
Whether this is better than your method is debatable. Most of the time a few lines of easy to read code is better than a one line hack.
My recommendation would be
name = ['Elon Reeve Musk']
initials="".join(word[0] for word in name[0].split())
f'{initials.lower()}@company.com'
>>> [email protected]
2
solved Create email with the firsts letters of the name [closed]