Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:31:55+00:00 2026-06-11T20:31:55+00:00

my_list = [‘1 ab ac bbba’,’23 abcba a aabb ab’,’345 ccc ab aaaaa’] I’m

  • 0
my_list = ['1 ab ac bbba','23 abcba a aabb ab','345 ccc ab aaaaa']

I’m trying to get rid of the numbers and the spaces, basically everything that’s not an ‘a’,’b’, or ‘c’

I tried this but it didn’t work and I’m not sure why:

for str in my_list:
    for i in str:
        if i != 'a' or 'b' or 'c':
            i = ''
        else:
            pass

I want to eventually get:

my_list2 = ['abacbbba','abcbaaaabbab','cccabaaaaa']
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:31:56+00:00Added an answer on June 11, 2026 at 8:31 pm

    Use re.sub to replace everything that is not a, b, or c, i.e., [^abc], with an empty string:

    import re
    my_list2 = []
    for str in my_list:
        my_list2.append(re.sub("[^abc]", "", str))
    

    DEMO.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my_list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'] Using python, I need list
My list view is parsed from a online resource, but i cant get the
I have a lists: my_list = ['abc-123', 'def-456', 'ghi-789', 'abc-456', 'def-111', 'qwe-111'] bad =
//file list.h #include stdafx.h namespace st { struct My_List; typedef My_List list; list* create(const
Below is my list of includes. When I run the program I get this
Consider a Python list my_list containing ['foo', 'foo', 'bar'] . What is the most
I'm trying to implement my own list class but am having trouble reversing just
How can I get my list of dt and dd to be on two
This is my list definition public class EventsList { public int EventID { get;
This is my list definition public class EventsList { public int EventID { get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.