The problem is msg = header + x . You are trying to apply the + operator to a row and list.
I'm not quite sure how you want to display x , but if you need something like "[1, 2, 3]", you will need:
msg = header + str(x)
Or you could do
msg = '{header}{lst}'.format(header=header, lst=x)
David sanders
source share