Legacy – Retrieving the Day Workout
- 02:13
Workout demonstrating how to retrieve the day using this library in Python.
Glossary
Dates Library Time Delta Library Times LibraryTranscript
Now we'll look at how to retrieve the current day given the date. To do that first thing we need to import the date and the date time modules. So from Date Time, import date from date time import data. So firstly we need to define that today is date . today. And then print today . weekday. It saying 2 what is 2 well, what Python is doing is it's by default it's giving a number which defines the current day by default pythons day. One of the week is a Monday, which is index zero index one is Tuesday. Index two is a Wednesday, and it goes also. But how do we get the actually what we need to do is we can define a list of days. And we can say that Monday Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday. And then we say print days of today . weekday. And we run this oh, there's an error because we defined it as days rather than a day. And it's Wednesday. Perfect. So it's referring back to our previous knowledge of indexing the lists. So we've defined a list of days and we are indexing a certain number simple