LoslegenKostenlos loslegen

Putting a list of dates in order

Much like numbers and strings, date objects in Python can be put in order. Earlier dates come before later ones, and so we can sort a list of date objects from earliest to latest.

What if our Florida hurricane dates had been scrambled? We've gone ahead and shuffled them so they're in random order and saved the results as dates_scrambled. Your job is to put them back in chronological order, and then print the first and last dates from this sorted list.

Diese Übung ist Teil des Kurses

Working with Dates and Times in Python

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Print the first and last scrambled dates
print(dates_scrambled[____])
print(dates_scrambled[____])
Code bearbeiten und ausführen