I'm fairly new to python so please excuse me if this is a stupid question. I'm having trouble with my elif statement. So, for example bedtimecalc will print out any number besides -18 or 18, but python keeps printing out the elif statement for -18 or 18. I hope that makes sense. I've tried both elif statements and regular if statements. I've looked this up and couldn't find an answer, so I do apologize again if this is a dupe. Also, I'm sure a bunch of if statements isn't the way to go about this, but I don't know what else to do. Thank you very much.
def main():
at = want_awaketime()
hs = want_hoursofsleep()
bedtimecalc = (int(hs)-int(at))
print (bedtimecalc)
if bedtimecalc == 0:
btf = "Midnight"
elif bedtimecalc == -1:
btf = "1am"
elif bedtimecalc == -2:
btf = "2am"
elif bedtimecalc == -3:
btf = "3am"
elif bedtimecalc == -4:
btf = "4am"
elif bedtimecalc == -5:
btf = "5am"
elif bedtimecalc == -6:
btf = "6am"
elif bedtimecalc == -7:
btf = "7am"
elif bedtimecalc == -8:
btf = "8am"
elif bedtimecalc == -9:
btf = "9am"
elif bedtimecalc == -10:
btf = "10am"
elif bedtimecalc == -11:
btf = "11am"
elif bedtimecalc == 12:
btf = "12pm"
elif bedtimecalc == 13:
btf = "1pm"
elif bedtimecalc == 14:
btf = "2pm"
elif bedtimecalc == 15:
btf = "3pm"
elif bedtimecalc == 16:
btf = "4pm"
elif bedtimecalc == 17:
btf = "5pm"
elif bedtimecalc == 18 or -18:
btf = "6pm"
elif bedtimecalc == 19:
btf = "7pm"
elif bedtimecalc == 20 or -20:
btf = "8pm"
elif bedtimecalc == 21:
btf = "9pm"
elif bedtimecalc == 22:
btf = "10pm"
elif bedtimecalc == 23:
btf = "11pm"
print ("Go to bed at " + btf + ".")
output
-20
Go to bed at 6pm.