Skip to content

Instantly share code, notes, and snippets.

@norbinsh
Created December 2, 2018 19:43
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 norbinsh/e6b82d0e05e186ece4d152e1944a2de7 to your computer and use it in GitHub Desktop.
Save norbinsh/e6b82d0e05e186ece4d152e1944a2de7 to your computer and use it in GitHub Desktop.
money_dict = {"Group": [[(17100.0, '1.07')], [(-22553.42, '1.07'), (106851.92, '1.07')], [(42000.0, '2')]]}
def recursive_tuple(data):
class TempBucket:
pass
bak = TempBucket()
bak.bucket = 0
def inner(data):
if isinstance(data, list):
for item in data:
inner(item)
else:
bak.bucket += data[0] / (float(data[1]) * 12)
inner(data)
return bak.bucket
print(recursive_tuple(money_dict['Group']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment