Adding elements to a list by number - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Adding elements to a list by number (/thread-24276.html) |
Adding elements to a list by number - Olavv - Feb-07-2020 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? RE: Adding elements to a list by number - buran - Feb-07-2020 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 RE: Adding elements to a list by number - ndc85430 - Feb-07-2020 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. RE: Adding elements to a list by number - Olavv - Feb-07-2020 (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? RE: Adding elements to a list by number - ndc85430 - Mar-08-2020 Do you know how to access items in a list by index? That's basically all you need. |