Menu

How do I get the date to correspond with the correct month, week and year?

Reddit r/learnpython·u/TheEyebal·7 months ago
#v2W6Xm8s
Reading 0:00
15s threshold

I am making a calendar in the CLI and I am stuck on adding the dates properly. How do I add it properly in my program

yearPick = input("Enter a year: ").lower() wk = ["MON", "TUE", "WED", "THUR", "FRI", "SAT", "SUN"] d = [1, 2, 3, 4, 5, 6, 7] if len(yearPick) != 4: print("Invalid Input") sys.exit() elif yearPick == "exit": sys.exit() else: monthPick = int(input("Enter a month (1-12): ")) if monthPick 12: print("Invalid Input") sys.exit() else: currentTime = datetime.datetime(int(yearPick), monthPick, 1) YEAR = currentTime.year MONTH = currentTime.strftime('%b') WEEK = currentTime.strftime('%w') DAY = currentTime.strftime('%d') title = "My CLI Calandar" table = f""" {title} {MONTH} {YEAR} {wk[0]} {wk[1]} {wk[2]} {wk[3]} {wk[4]} {wk[5]} {wk[6]} _________________________________________________________ |{d[0]} |{d[1]} |{d[2]} |{d[3]} |{d[4]} |{d[5]} |{d[6]} | |_______|_______|_______|_______|_______|_______|_______| | | | | | | | | |_______|_______|_______|_______|_______|_______|_______| | | | | | | | |…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.