May-08-2021, 05:41 AM
Greetings!
I'm looking for a line that has multiple spaces and the word "Motherboard:" at the beginning of the line.
If it found I would split the line and get the fourth element, which is a Serial number.
I'm trying to test splitted elements and if an element [4]==0 write something else instead.
I was sure it will work but it does not. I got this error "IndexError: list index out of range"
I'm looking for a line that has multiple spaces and the word "Motherboard:" at the beginning of the line.
If it found I would split the line and get the fourth element, which is a Serial number.
I'm trying to test splitted elements and if an element [4]==0 write something else instead.
I was sure it will work but it does not. I got this error "IndexError: list index out of range"
if ' Motherboard:' in rn_l : mb=re.split(r" {2,}", rn_l) if not mb[4] : mb[4] ="No Serial Num" else : print (f" Motherboard Serial number -->> {mb[4]}")