Python Forum

Full Version: Adding elements to a list by number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I add elements to a list by number?
If I wanted to add elements that are grouped in three's from a list to three other lists, how would I do it?

For example if the numbers under was in a list called raw:
23
45
24
09
18
23
65
78
61
How would I get the first three, the middle three, and then the last into three different lists?
you can do this by using just Standard library, but if not restricted to install and use third party libraries, look at more-itertools package
What have you thought about? You don't necessarily need any libraries to do this, but can do it with the basic operations that you can perform on lists.
(Feb-07-2020, 02:10 PM)ndc85430 Wrote: [ -> ]What have you thought about? You don't necessarily need any libraries to do this, but can do it with the basic operations that you can perform on lists.
What basic operations?
Do you know how to access items in a list by index? That's basically all you need.