Working with Dates and Times in Python
Max Shron
Data Scientist and Author
two_hurricanes = ["10/7/2016", "6/21/2017"]
How would you:
# Import date from datetime import date
# Create dates two_hurricanes_dates = [date(2016, 10, 7), date(2017, 6, 21)]
# Import date from datetime import date # Create dates two_hurricanes_dates = [date(2016, 10, 7), date(2017, 6, 21)]
print(two_hurricanes_dates[0].year) print(two_hurricanes_dates[0].month) print(two_hurricanes_dates[0].day)
2016
10
7
print(two_hurricanes_dates[0].weekday())
4
Working with Dates and Times in Python