I have a list in which I copy elements from another list (possiblePartitions). At the same time, I have created a second list in which I enter the same values manually (posiblePartitions2 ).
possiblePartitions = getPossiblePartitions(setOfElements)[48:50] posiblePartitions2 = [[['1.1', '2.1'], ['1.2'], ['2.2'], ['2.3', '2.4']],[['1.1', '2.2'], ['1.2'], ['2.1'], ['2.3', '2.4']] ]Output for both lists:[[['1.1', '2.1'], ['1.2'], ['2.2'], ['2.3', '2.4']], [['1.1', '2.2'], ['1.2'], ['2.1'], ['2.3', '2.4']]]The string numbers present tasks that are to be executed one after the other. I use a function to insert additional tasks between these tasks. I use this function in a for loop. Inserting works with the manual list. Something is overwritten in the copied list. Why is this?
for el in mylist: print(insert_secondary_actions(el))Output: [['S-1.1', '1.1', 'C-2.1', '2.1', 'E-2.1'], ['S-1.2', '1.2', 'E-1.2'], ['S-2.2', '2.2', 'E-2.2'], ['S-2.3', '2.3', 'R-2.3', '2.4', 'E-2.4']][['S-1.1', '1.1', 'C-2.2', '2.2', 'E-2.2'], ['S-1.2', '1.2', 'E-1.2'], ['S-2.1', '2.1', 'E-2.1'], ['S-2.3', '2.3', 'R-2.3', '2.4', 'E-2.4']]for el2 in possible_allocations: print(insert_secondary_actions(el2))Output:[['S-1.1', '1.1', 'C-2.1', '2.1', 'E-2.1'], ['S-1.2', '1.2', 'E-1.2'], ['S-2.2', '2.2', 'E-2.2'], ['S-2.3', '2.3', 'R-2.3', '2.4', 'E-2.4']][['S-1.1', '1.1', 'C-2.2', '2.2', 'E-2.2'], ['S-S-1.2', 'S-1.2', 'C-1.2', '1.2', 'C-E-1.2', 'E-1.2', 'E-E-1.2'], ['S-2.1', '2.1', 'E-2.1'], ['S-S-2.3', 'S-2.3', 'C-2.3', '2.3', 'C-R-2.3', 'R-2.3', 'C-2.4', '2.4', 'C-E-2.4', 'E-2.4', 'E-E-2.4']]The second last line in the output should not contain any letters. Why are they included?