Skip to content

Instantly share code, notes, and snippets.

@de1o
Created May 14, 2014 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save de1o/2495bd648c72f79a426a to your computer and use it in GitHub Desktop.
Save de1o/2495bd648c72f79a426a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def format_dict(array):
return {array[0]: {array[1]: array[2],
array[3]: array[4]}}
def proc(array):
if (len(array) % 5):
raise Exception
return [format_dict(array[i: i+5]) for i in xrange(0, len(array), 5)]
print proc([x for x in xrange(1, 11)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment