0

How to clear values in list without affecting the dependant list??pls answer

I've attached the code (input = 1,2,3,4) The desired output is: [[1,2 ],[3,4 ]] But the output is [[ ],[ ]] Pls answer.. https://code.sololearn.com/czYHB4TDI5Mr/?ref=app https://code.sololearn.com/czYHB4TDI5Mr/?ref=app

20th Apr 2020, 5:36 PM
Akash s
Akash s - avatar
3 Answers
+ 2
little change in line 7 data.append(data2[::])
20th Apr 2020, 5:50 PM
Oma Falk
Oma Falk - avatar
+ 3
l=[1,2,3,4] x=[[l[i],l[i+1] ] for i in range(0,len(l),2)] print(x) I hope it helps!!!
20th Apr 2020, 5:48 PM
ANJALI SAHU
+ 2
Thank you very much for your responses.
20th Apr 2020, 7:14 PM
Akash s
Akash s - avatar