You can only pass a simple string variable to a script from PAD, and anything returned by a script to PAD will also be a string. So, you need to work with strings and then build in processing for the string (such as splitting it into a list) into your script (if you want to pass it from PAD to a script) or in your PAD flow (if you want to return it from a script to your PAD flow).
-------------------------------------------------------------------------
If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.
I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.