vendredi 19 juin 2020

Fill a list condition to another regarding values

I have the following question. I have 3 lists which are the below.

The list with Department Names: Department_List = ["Department_1", "Department_2"] len("Department_List") = 2

The list with Category Names: Category_List = ["Cat_1","Cat_3","Cat_1","Cat_2",....... ,"Cat_5"] len("Category_List ") = 10000

Empty List SubCategory: SubCategory_List = []

The task i have to do is the following. I want to random fill the SubCategory_List with values from Department_List. The problem is that i want the same elements from the Category_List, to have the same values for Department Name.

For example, the outcome would be something like this in case that Cat_1 = Department_1, Cat_3 = Department_2, Cat_2 = Department_2 and Cat_5 = Department_1:

SubCategory_List = ["Department_1","Department_2","Department_1","Department_2",....... ,"Department_1"]

Notice. I must not do it with Dictionary!

Thank you!




Aucun commentaire:

Enregistrer un commentaire