Why is it showing run time error? But it is working properly on cb ide

Hello @mb129162,

I have corrected your code:


Refer to comments for better understanding.

Hope this would help.
Give a like if you are satisfied.