If you have an error saying the lengths need to be the same, have you checked the lengths of the things you’re using? Seems like the obvious thing to look at don’t you agree?
And, you did things earlier in your code, just because an error happens at one location doesn’t mean that’s where the mistake is.
Getting yourself a crystal clear idea of what it is your code is supposed to be doing will help you as well. If you’re just copying and then get an error then it’s not such a big surprise if it’s difficult to fix. So you’d want to know what your program is supposed to do all the way through, and you’d want to know what the behaviour is for all the operations that you’re using to describe those actions.