I've recently started coding in python. I am trying to create an environment variable and assign list to it using python. So when I try to read my environment variables through command line like printenv it will be listed there. 
This is my code in python:
from API_CALLS import Post_Request as Request
import os
class VTM_Config:
    @staticmethod
    def validate_pool_nodes(url, headers, expected_num_of_active_nodes):
        try:
            print('\nNow Executing Validate VTM Configs...\n')
            # validate that vtm api works by sending a get_session_with_ssl call to the url
            vtm_get_session_response = Request.get_session_with_ssl(url=url, headers=headers)
            data = vtm_get_session_response
            active_nodes = [
                n['node']
                for n in data['properties']['basic']['nodes_table']
                if n['state'] == 'active'
            ]
            actual_num_of_active_nodes = len(active_nodes)
            if expected_num_of_active_nodes != actual_num_of_active_nodes:
                print("Number of Active Nodes = {}".format(actual_num_of_active_nodes))
                raise Exception("ERROR: You are expecting : {} nodes, but this pool contains {} nodes".format(
                    expected_num_of_active_nodes, actual_num_of_active_nodes))
            else:
                print("Number of Active Nodes = {}\n".format(actual_num_of_active_nodes))
            print("Active servers : {}\n".format(active_nodes))
            os.environ["ENABLED_POOL_NODES"] = active_nodes
            return os.environ["ENABLED_POOL_NODES"]
        except Exception as ex:
            raise ex
I am trying to create an environment variable using         os.environ["ENABLED_POOL_NODES"] = active_nodes and trying to return it. 
When I run this code, I am getting an error like this: raise TypeError ("str expected, not %s % type(value).name) TypeError: str expect, not list.
Question: How do I assign list to an environment variable.
 
    