I want to edit my code below to catch all strings which END with "_C[any letter/ any number/ or nothing]"
Here is my list
name_list = ['chrome_PM',
'chrome_P',
'chromerocker_C',
'chromebike_P1',
'chromecar_CMale',
'chromeone_C1254',
'Lukate_Aids_Consumer_P']
for name in name_list:
counts_tail = re.compile('_C[\da-zA-Z_]*$')
if counts_tail.search(name):
print name
output:
chromerocker_C
chromecar_CMale
chromeone_C1254
Lukate_Aids_Consumer_P
expected output:
chromerocker_C
chromecar_CMale
chromeone_C1254
'Lukate_Aids_Consumer_P' should not be included because it doesnt END with '_C', how can I edit my code to handle this bug?
Thanks
chromecar_CMalechromeone_C1254chromecar_CMaleandchromeone_C1254only with your current code.