[Tutor] What is day of week from either 20180211 or 02112018

David Rock david at graniteweb.com
Tue Feb 6 15:20:12 EST 2018


> On Feb 6, 2018, at 13:45, Ken Green <beachkidken at gmail.com> wrote:
> Traceback (most recent call last):
>   File "A_Weekday.py", line 20, in <module>
>     answer = datetime.date(year, month, day).weekday()
> NameError: name 'datetime' is not defined

Your error message tells you the problem.  You are importing date _from_ datetime, but then try to call datetime.date

> from datetime import date

You have _not_ imported date time, so the program doesn’t know what you mean when you say

answer = datetime.date(year, month, day).weekday()

Try just doing 

import datetime 

instead.


— 
David Rock
david at graniteweb.com






More information about the Tutor mailing list