python break list into n lists

Solutions on MaxInterview for python break list into n lists by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "python break list into n lists"
Greta
12 May 2016
1def even_divide(lst, num_piece=4):
2    return [
3        [lst[i] for i in range(len(lst)) if (i % num_piece) == r]
4        for r in range(num_piece)
5    ]