Reverse username from email

Question:

I created a script whereas the output should be "ACER,ONE" however I am stuck how can I place a reverse the username which I ended up "ONE,ACER" as result.

email='[email protected]'
index = email.index("@")
email_id = email[:index]
email_id = email_id.upper()
print(email_id.replace(email_id[3],","))
# > ONE,ACER
Asked By: ndc

||

Answers:

",".join("ACER,ONE".split(",")[::-1])

In your case, you could do:

print(",".join(email.split("@")[0].split(",")[::-1]))

as @ox5453 mentioned in the comments, you can also use the built-in reversed method for readability:

print(",".join(reversed("ACER,ONE".split(","))))
print(",".join(reversed(email.split("@")[0].split(","))))
Answered By: jjislam
email1 ='[email protected]'
email2 = print(",".join(reversed("ONE,ACER".split(","))))

This is my answer which I got
ACER,ONE

Answered By: ndc
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.