[Python] Remove email addresses from Python list using .rstrip("@")

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have a list of email addresses and I would like to remove everything after "@". My code looks like this so far:

    user_emails = ['me@organization.org', 'you@organization.org', name@organization.org'] emails = [user.rstrip("@") for user in user_emails]

    But nothing changes when I run this code. When I run:

    emails = [user.strip("@organization.org") for user in user_emails]

    The @ is removed but so is the character to the left of it, which is no good for me.

    Is there something I should be doing to remove this character?

    Thanks for any insight.

    Continue reading...

Compartilhe esta Página