Pyton code errorr

I am new to pyton i am getting an error on pyton code.

error

   level = elem[prod_pos].count(':')
IndexError: list index out of range

I am not sure how to debug the pyton code in run time.

Hey @keerthi2021, I already posted an answer to your problem here: Pyton code error - #2 by DiddiLeija