Skip to content

Instantly share code, notes, and snippets.

@ZSendokame
Created June 22, 2024 00:50
Show Gist options
  • Save ZSendokame/efb15d4f0f6eb907c90ef198e9f7052b to your computer and use it in GitHub Desktop.
Save ZSendokame/efb15d4f0f6eb907c90ef198e9f7052b to your computer and use it in GitHub Desktop.
Make dictionaries by list segments.
def relindex_value(iterable: list, column: list) -> list[dict]:
result = []
aux = {}
for index, item in enumerate(iterable):
aux[column[index % len(column)]] = item
if (index % len(column)) == (len(column) - 1):
result.append(aux)
aux = {}
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment