Array not taking value

Below is the prograame in solidity I wrote which assigns value to elements of an array.

pragma solidity 0.8.16 ;
 contract arr
      uint i = 0 ;
     people[] public person ;

     struct people
         uint256 num ;
         string name ;

     function plus(string memory naam , uint256 nu) public
       person[i].num = nu ;
       person[i].name = naam ;
        i++ ;


Instead of push function I want to put values like this . While compilation and deploying no error comes however when I call this function then this error shows :-

It reads:-

The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.
Debug the transaction to get more information.

I want to know what I am doing wrong , and why is it asking me to make the function payable.

Thank You

from that error it looks like you tried to send eth when calling that function

No , I did not. I simple exeucted the programme. You can copy the pgm in your remix and try , same error will come. I did not tried to send any ether .

you could try to debug it in remix to see what happens

you might be trying to access and array index that doesn’t exist
why not push it:

person.push(people(nu, naam));

then allow them to edit it:

person[i].num = nu ;
person[i].name = naam ;

in that case a mapping might be a better data structure.

you might have to specify the array length if you want to edit those indexes without pushing, such as:

people[10] public person ;

hope that helps!

Happy thanksgiving btw