I have this class when never i execute it it give me this error
I know the error in day_name = self.day
the day is being read as is it instead of variable
Traceback (most recent call last): File "c:\Users\LENOVO\Documents\python\usefull\test.py", line 19, in day_is_1 = ob.get_day(day_1) File "c:\Users\LENOVO\Documents\python\usefull\test.py", line 13, in get_day day_name = self.day AttributeError: 'Days' object has no attribute 'day'
class Days:
def __init__(self):
self.mo = "monday"
self.tu = "tuesday"
self.we = "wednesday"
self.th = "thursday"
self.fr = "friday"
self.sa = "saturday"
self.su = "sunday"
def get_day(self,day):
day_name = self.day
print(day_name)
day_1 = "mo"
day_2 = "tu"
ob = Days()
day_is_1 = ob.get_day("mo")
day_is_2 = ob.get_day("tu")