Feb-18-2021, 09:47 PM
Hi,
I'm 'splitting' a string and if an 'empty element found I'm trying replacing it with an "EMPTY ELEMENT"
Code:
if sp_l_fapp[2] :
IndexError: list index out of range
I'm 'splitting' a string and if an 'empty element found I'm trying replacing it with an "EMPTY ELEMENT"
Code:
import os l_f = 'ELEMET-0,ELEMET-1' sp_l_fapp = l_f.split(",") if sp_l_fapp[2] : sp_l_fapp[2]=sp_l_fapp[2].strip() print (" SPLITED--->>> ",sp_l_fapp[2]) else : sp_l_fapp[2] = 'EMPTY ELEMENT' print (" Priduct Line is empty ! ! ! -->> ",sp_l_fapp[2])But still getting an error:
if sp_l_fapp[2] :
IndexError: list index out of range