'how get I a return value from a gather method

I want to have the return value of the task_2 function, but it doesn't work the way I want it to. Actually, I want the return from the task_2 function as a usable value in the main function so that I could use it for another function

class test_class():
    def __init__(self):
        self.list_el = [1,2,3,4,5,6]
        self.loop = asyncio.get_event_loop()


    def main(self):
        return_value = self.loop_1()
        print(return_value)

    def loop_1(self):
        output = self.loop.run_until_complete(self.task_1())
        return output

    async def task_1(self):
        tasks = []
        for i in self.list_el:
            tasks.append(asyncio.create_task(self.task_2(i)))
        return tasks

    async def task_2(self,number):
        odd = []
        even = []
        if number % 2 ==0:
            print("even")
            even.append(number)
        else:
            print("odd")
            odd.append(number)

        return even,odd

if __name__ == "__main__":
    app =test_class()
    app.main()



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source