redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

one liner solution for changing a list



 
Post new topic   Reply to topic    Web Design Forums -> Python programming forum
View previous topic :: View next topic  
Author Message
Koplaf



Joined: 28 May 2006
Posts: 130
Is there any quick one-liner solution for changing a list of [1,2,3,4,1,2,3,4,...] into [[1,2,3,4], [1,2,3,4], ....] (ie. group the list into sublists with four values)?
  Reply with quote


Kopilman



Joined: 25 May 2006
Posts: 162
[foo[i:i+4] for i in range(0, len(foo), 4)]
  Reply with quote
Page 1 of 1
Post new topic   Reply to topic    Web Design Forums -> Python programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group