Question for dividing Python list.

Asked 2 years ago, Updated 2 years ago, 76 views

Hello, I'm a beginner in programming. I want to divide the elements in the list into random sizes, what should I do?

a = [ 1, 2, 3, 4, 5, 6, 7, 8]

#At the time of output
a = [[1,2],[3,4,5],[6,7],[8]]
a = [[1,2,3],[4,5],[6,7,8]] 
a = [[2,5,4],[1,3],[6,7,8]]

I want to divide the elements in the list randomly while shuffling, but I don't know how to do it, so I leave a question like this. I'd appreciate your help.

python python-2.7

2022-09-21 16:29

1 Answers


2022-09-21 16:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.