Skip to content
Advertisement

Creating multiple sublists in Python

I have a list J with len(J)=2. I want to create a sublist of each element in J[i] where i=0,1. I present the current and expected output.

JavaScript

The current output is

JavaScript

The expected output is

JavaScript

Advertisement

Answer

you can try this,

JavaScript

this will give you [[[1], [2], [4], [6], [7]], [[1], [4]]]

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement