Also Can you pls help me with my code

I have written code similar to mam’s but it is showing an error(out of bounds) in mine. Can u pls tell me what is wrong?