import pendulum items = [ {'name': 'Milk', 'expire_date': '2024-09-15'}, {'name': 'Bread', 'expire_date': '2024-09-18'}, {'name': 'Yogurt', 'expire_date': '2024-09-25'}, ] def check_expire_date(items): for item in items: expire_date = pendulum.parse(item.get('expire_date')) cuurent_date = pendulum.now() if expire_date <= cuurent_date: print(f' {item.get('name')} expired') check_expire_date(items=items)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter