adding a new value to list overwrite previous values in the list

I’m trying to add multiple items to a list but at the end all items have the same value equal to last item public static List<Ausencias> SeparateMonth(Ausencias aus) { List<Ausencias> ausencias = new List<Ausencias>(); try { var resultSplit = Helper.SplitFechas(aus.PI_StartDate, aus.PI_EndDate); if (resultSplit.Count > Constant.ONE) { foreach (var item in resultSplit) { Ausencias ausenc =… Read More adding a new value to list overwrite previous values in the list

Creating multiple sublists by performing an operation in Python

I have two lists A2 and Cb_new. I am performing an operating as shown below. But I want to create multiple sublists instead of one single list. I present the current and expected outputs. A2=[[2, 3, 5], [3, 4, 6]] Cb_new=[[1.0, 0.0, 0.0, 0.9979508721068377, 0.0, 0.9961113206802571, 0.0, 0.0, 0.996111320680257, 0.0, 0.0]] Cb=[] for j in… Read More Creating multiple sublists by performing an operation in Python

Removing elements from a list based on indices in another list in Python

I have a list J. I want to remove specific elements from J[0] based on index. For example, I want to remove J[0],J[3] based on elements in index. But I am getting an error. I present the expected output. J=[[2, 6, 9, 10]] index=[[0,3]] for i in range(0,len(J)): for k in range(0,len(index)): J[i].remove(index[k][0]) print(J) The… Read More Removing elements from a list based on indices in another list in Python