This is my code:
class MyTime:
def __init__(self, hrs=0, mins=0, secs=0):
self.hours = hrs
self.minutes = mins
self.seconds = secs
if self.seconds >= 60:
self.minutes += self.seconds // 60
self.seconds = self.seconds % 60
if self.minutes >= 60:
self.hours += self.minutes // 60
self.minutes = self.minutes % 60
if self.hours >= 24:
self.hours = self.hours % 24
def get_sec(self):
return (self.hours * 60 + self.minutes) * 60 + self.seconds
def __str__(self):
return "{:02d}:{:02d}:{:02d}".\
format(self.hours, self.minutes, self.seconds)
def between(self, t1, t2):
return (t1.get_sec()) <= (self.get_sec()) and (self.get_sec()) <= (t2.get_sec())
t1 = (9, 59, 59)
print("t1 =", t1)
t2 = (10, 0, 1)
print("t2 =", t2)
t3 = (10, 0, 0)
print("t3 =", t3)
print (t2.between(t1, t3))
I keep getting an error: AttributeError: 'tuple' object has no attribute 'between'
The traceback says: Traceback (most recent call last):
File "<string>", line 420, in run_nodebug
File "C:\Users\Desktop\module1.py", line 40, in <module>
print t2.between(t1, t3)
AttributeError: 'tuple' object has no attribute 'between'
Any help would be great, thank you!