use python script as animation node, and give it inputs
Script node works the same way the other subprograms work in Animation Nodes:


Define a subprogram
Then invoke it from another part of the node tree


Let say we have:


a simple text block with some code in it. Here it calculates a string from a list of objects
a group of objects composed here by a cube, a plane, a circle (objects are grouped using CtrlG)


And we want to use the text value of the script to be the text displayed by the text object on the right:



Here in this script 'text' (a string or a text type in AN) will be the result and 'objects' (a list of objects) will be the input.

You can do the following:


Add an object group node. Set it to the objects group's name
Add a text object output node. Set it to the text object.





Add a subprogram as script.
Set its input and choose "object list" as type. Eventually rename the input variable value (here we need to rename it to 'objects').
Set its output and choose "text". Rename it if needed (here we want it to be named 'text').





Add the invoke subprogram node which corresponds to our subprogram's name ("my script" here but you can rename it) and connect input and output of this node.