Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Compliance Tracker | Supporting Legal Research and Compliance
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Legal Professionals

bookChallenge: Compliance Tracker

When tracking compliance events, you often need to identify which deadlines are approaching soon. In Python, you can use the datetime module to parse string dates, compare them to today's date, and filter for events occurring within a specific time window. Begin by representing your compliance events as a list of dictionaries, each containing an event name and a due date in string format (such as "2024-07-15"). To work with these dates, use datetime.strptime() to convert the string into a datetime.date object. You can then get today's date using datetime.date.today(), and calculate the difference in days between each event's due date and today. By filtering for events where this difference is between 0 and 7, you'll identify all compliance events due within the next week. This approach is useful for legal professionals who need to stay on top of imminent deadlines and avoid compliance issues.

Uppgift

Swipe to start coding

Write a script that identifies and displays compliance events due within the next 7 days. The function receives a list of events, each with a name and a due date string, and today's date as a string.

  • Parse each event's due date string into a date object.
  • Parse today's date string into a date object.
  • Calculate the number of days between today's date and each event's due date.
  • For each event due within 0 to 7 days (inclusive), include it in the results.
  • Display the name and due date of each upcoming event.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 3
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Can you show me an example of how to implement this in Python?

How can I modify the time window to look for events due in the next 30 days?

What should I do if my date strings are in a different format?

close

bookChallenge: Compliance Tracker

Svep för att visa menyn

When tracking compliance events, you often need to identify which deadlines are approaching soon. In Python, you can use the datetime module to parse string dates, compare them to today's date, and filter for events occurring within a specific time window. Begin by representing your compliance events as a list of dictionaries, each containing an event name and a due date in string format (such as "2024-07-15"). To work with these dates, use datetime.strptime() to convert the string into a datetime.date object. You can then get today's date using datetime.date.today(), and calculate the difference in days between each event's due date and today. By filtering for events where this difference is between 0 and 7, you'll identify all compliance events due within the next week. This approach is useful for legal professionals who need to stay on top of imminent deadlines and avoid compliance issues.

Uppgift

Swipe to start coding

Write a script that identifies and displays compliance events due within the next 7 days. The function receives a list of events, each with a name and a due date string, and today's date as a string.

  • Parse each event's due date string into a date object.
  • Parse today's date string into a date object.
  • Calculate the number of days between today's date and each event's due date.
  • For each event due within 0 to 7 days (inclusive), include it in the results.
  • Display the name and due date of each upcoming event.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 3
single

single

some-alt