But if you can get the height of the terminal then you can use something like this this
Assuming your input is a generator/list of line seperated text, or else you can call text.split('\n') before calling this function