special elimination



    Mahendra Kumar


    Python program to remove all special characters from list

    # importing RegEx module
    import re
    # take list
    my_list = ['@know*', 'pr#ogra!m^', '(py_th@on_3}']
    # using regular expression to remove special characters
    out_list = [re.sub(r'[^a-zA-Z0-9]','',string) for string in my_list]
    # print list without special characters
    print('List after removal of special characters:', out_list)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.