I've been trying to fix this code for an hour and I don't quite understand how it's accessing one of the other lists when it's not meant to. For example when I pick a day then I ask for it to be a character (char) then it just outputs the full day...same thing happens with a short day.
class dateformat:
def __init__(self):
self.dyfull = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
"Sunday"]
self.shortdy = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
self.chardy = ["M", "T", "W", "T", "F", "S", "S"]
self.dy = 0
self.formt = ""
pass
def getday(self):
self.day = int(input("What day is it? (Number): ")) - 1
def getformat(self):
self.formt = str(input("What format would you like? "
"[Day, Shortday, Char]: "))
def outputday(self):
if self.formt == "Day" or "day":
print(self.dyfull[self.day])
elif self.formt == "Shortday" or "shortday":
print(self.shortdy[self.day])
elif self.formt == "Char" or "char":
print(self.chardy[self.day])
else: print("No work")
dat = dateformat()
dat.getday()
dat.getformat()
dat.outputday()