Created
May 14, 2014 16:42
-
-
Save de1o/2495bd648c72f79a426a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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