Skip to content

Instantly share code, notes, and snippets.

@epignatelli
Last active February 5, 2026 13:54
Show Gist options
  • Select an option

  • Save epignatelli/f6d9b634afed515515dfe36ec2e632cd to your computer and use it in GitHub Desktop.

Select an option

Save epignatelli/f6d9b634afed515515dfe36ec2e632cd to your computer and use it in GitHub Desktop.
import datetime as dt
def f(x):
"""Sums purchase amounts for UK entries.
Args:
purchases: List of dicts with keys "country" and "amount".
Returns:
Total amount for purchases where country == "UK".
"""
t=0
for i in x:
if i[ "c" ]=="UK":
try: t+=float(i [ "a" ])
except: pass
print("TOTAL",t,"@",dt.datetime.now());return t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment