The goal of the function is to output a value in a given range. Including the start and end value if it is entered as input. The function only outputs the expected result for values at the start and between the range.
def main():
#assume user input will be formatted in 24-hour time as #:## or ##:##
time = input("What is the time: ")
if time >= "7.0" and time <= "8.0":
print("breakfast time")
elif time >= "12.0" and time <= "13.0":
print("lunch time")
elif time >= "18.0" and time <= "19.0":
print("dinner time")
def convert(time):
h, m = time.split(":")
time = float(((float(h) * (60)) + float(m)) / 60)
return time
if __name__ == "__main__":
main()
- current output when input is i.e 8:00 --> ""
- expected output when input is i.e 8:00 --> breakfast
You need first to call you
convert
method, and change the conditions to avoid exception comparingstring
withfloat