Welcome in the Community!
Your code is not well readable here. If you enclose it with three backticks (before and after your code) it will be much better readable.
(On my keyboard I have a backtick on the key left of the '1' key but by clicking the </> button in the Reply panel you get Preformatted text with backticks around it.)
The error seems to indicate that something is wrong with result : it is a list and not a number or numbers. Could it be that the result is empty where you expected a number?