Python Forum
can't remove element from a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can't remove element from a list
#1
i have a list and i want to remove all non digit element from it,but got some problem.
there is my code , can you help me:



match = re.compile(r'ROL N°.[0-9][0-9].')

case_title = re.sub(match,'',expression) 
num_case= match.search(expression)

first_case_num=[]
 first_case_num = num_case.group()
 second_case_num=  num_case.group()
    
    for case in first_case_num:
        if case.isdecimal():
            pass
        else:
             first_case_num.remove(case)
Quote:---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-91-521c272a0c4b> in <module>
27 print(case)
28 else:
---> 29 first_case_num.remove(case)
30
31

AttributeError: 'str' object has no attribute 'remove'
Reply


Messages In This Thread
can't remove element from a list - by yokaso - Nov-06-2019, 10:22 AM
RE: can't remove element from a list - by perfringo - Nov-06-2019, 10:36 AM
RE: can't remove element from a list - by yokaso - Nov-06-2019, 10:45 AM
RE: can't remove element from a list - by perfringo - Nov-06-2019, 10:55 AM
RE: can't remove element from a list - by yokaso - Nov-06-2019, 11:53 AM
RE: can't remove element from a list - by perfringo - Nov-06-2019, 02:09 PM
RE: can't remove element from a list - by yokaso - Nov-06-2019, 03:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sume Every 10 element in the list and Divided of Sum quest_ 7 135 Yesterday, 10:58 AM
Last Post: perfringo
  Counting Element in Multidimensional List quest_ 1 91 Nov-25-2020, 10:00 PM
Last Post: quest_
  Adding List Element if Second part of the List Elements are the Same quest_ 3 121 Nov-25-2020, 04:33 PM
Last Post: bowlofred
  Removing element from list squall 6 171 Nov-22-2020, 09:34 PM
Last Post: jefsummers
  2d Array adds last element to entire list waiteup 2 96 Nov-19-2020, 08:25 PM
Last Post: bowlofred
  How to get index of minimum element between 3 & 8 in list Mekala 2 162 Nov-10-2020, 12:56 PM
Last Post: DeaD_EyE
  Remove double quotes from the list ? PythonDev 22 668 Nov-05-2020, 04:53 PM
Last Post: snippsat
  Problem printing last element from a list tester_V 3 196 Oct-30-2020, 04:54 AM
Last Post: tester_V
  Remove specific elements from list with a pattern Xalagy 3 338 Oct-11-2020, 07:18 AM
Last Post: Xalagy
  How to remove dict from a list? Denial 7 277 Sep-28-2020, 02:40 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020