How to match word in list when i used demo in https://regex101.com/ it's match with \w+ but when I threw in my code the word not detected, So this is my code:
def MultiTrain(self):
for fitur in self.fiturs:
if (fitur[0] == 'F7') or (fitur[0] == 'F8') or (fitur[0] == 'F9') or (fitur[0] == 'F10') or (
fitur[0] == 'F13') or (fitur[0] == 'F14') or (fitur[0] == 'F15') or (fitur[0] == 'F16') or (
fitur[0] == 'F17') or (fitur[0] == 'F23') or (fitur[0] == 'F24') or (fitur[0] == 'F25') or (
fitur[0] == 'F26') or (fitur[0] == 'F27') or (fitur[0] == 'F28') or (fitur[0] == 'F29') or (
fitur[0] == 'F30') or (fitur[0] == 'F37') or (fitur[0] == re.findall('\w+', fitur[0])) :
print fitur
and this is the word i want to match with regex:
F37,0,1,0,1,1,1,0,1,0,2
F7,0,0,0,0,0,0,1,0,1,0
F11,0,0,1,0,0,1,0,0,0,0
angkasa,1,0,1,0,0,0,0,0,0,0
action,0,1,0,0,0,0,0,0,0,0
acu,0,0,0,0,1,0,0,0,0,0
ampun,0,0,0,0,0,0,0,1,0,0
The output of the program is:
F37,0,1,0,1,1,1,0,1,0,2
F7,0,0,0,0,0,0,1,0,1,0
F11,0,0,1,0,0,1,0,0,0,0
but my expectation is:
F37,0,1,0,1,1,1,0,1,0,2
F7,0,0,0,0,0,0,1,0,1,0
F11,0,0,1,0,0,1,0,0,0,0
angkasa,1,0,1,0,0,0,0,0,0,0
action,0,1,0,0,0,0,0,0,0,0
acu,0,0,0,0,1,0,0,0,0,0
ampun,0,0,0,0,0,0,0,1,0,0
the fitur[0] with word not detected just the F37-F11 How can I fix the regex?
if fitur[0] in ..., it makes for a far more readable code.