Ian Murray
Ian Murray

Reputation: 87

Issue with datetime module

I'm trying to make a simple Python function that prints two things;

  1. What day of the week it currently is.
  2. How many days it is until Christmas.

I don't get any errors when I run this, however nothing prints either. In fact nothing at all happens when its run.

I've checked and I've installed the datetime module correctly (I think).

Screenshot of cmd prompt confirmation

I'm not really sure what I'm doing wrong so any guidance would be helpful.

As you can probably guess, I'm relatively new to Python/stackoverflow.

Thanks.

Edit: I stupidly named the file itself datetime.py because yes I am that stupid.

from datetime import *

def day_of_week():
    """ Python function to return a specified day of the week"""
    today_date = date.today()

    thisYear = today_date.year
    xmas = date(thisYear,12,25)

    day_of_week =("Mon","Tue","Wed","Thu","Fri","Sat","Sun")[today.weekday]
    print("It's a %s." % (day_of_week))

    days_to_xmas = (xmas - today_date).days
    print("There are %i days to xmas!" & days_to_xmas)

Upvotes: 1

Views: 60

Answers (1)

manoj yadav
manoj yadav

Reputation: 347

Try calling the function in the script , you defined the function but never executed it.

day_of_week()

Upvotes: 1

Related Questions