0
import time
import datetime

date = time.strftime("%A")
week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];
weekend = ["Saturday", "Sunday"];

if weekend == date:
    print ("Today is: " + date)

/I want to make schedule. So when a day is equal with one of my days saved in variable it will print out my schedule for that date. As you can see I dont have the schedules yet. I just need ot know how to save current day as string/

Daniel Radosa
  • 71
  • 3
  • 14
  • 2
    Have a look at the following SO answer. This will give you the date https://stackoverflow.com/a/29519293/8411228 – Uli Sotschok Oct 21 '18 at 16:24
  • I guess you have the `date` variable correct, i.e., name of day as string. But the `if` check is faulty, it's comparing a list with a string. – Vikrant Sharma Oct 21 '18 at 16:32
  • Possible duplicate of [How do I get the day of week given a date in Python?](https://stackoverflow.com/questions/9847213/how-do-i-get-the-day-of-week-given-a-date-in-python) – Oleksii Oct 21 '18 at 18:36

1 Answers1

0

You want to check if date is in either of the two collections, week or weekend. Like:

if date in week:  # or weekend
    print('Weekday')

Use sets for more efficient checking, like:

weekend = set(["Saturday", "Sunday"])

Also, no semicolons to end a statement.

Vikrant Sharma
  • 419
  • 3
  • 6