Birth_date 是 1 到 2359 之间的整数。每只动物也是列表的一部分。我想将出生日期转换为列表索引,但我不确定如何。
if (birth_time >= 2300) or (birth_time < 100):
hour_animal = "RAT"
elif (birth_time >= 100) and (birth_time < 300):
hour_animal = "OX"
elif (birth_time >= 300) and (birth_time < 500):
hour_animal = "TIGER"
elif (birth_time >= 500) and (birth_time < 700):
hour_animal = "RABBIT"
elif (birth_time >= 700) and (birth_time < 900):
hour_animal = "DRAGON"
elif (birth_time >= 900) and (birth_time < 1100):
hour_animal = "SNAKE"
elif (birth_time >= 1100) and (birth_time < 1300):
hour_animal = "HORSE"
elif (birth_time >= 1300) and (birth_time < 1500):
hour_animal = "SHEEP"
elif (birth_time >= 1500) and (birth_time < 1700):
hour_animal = "MONKEY"
elif (birth_time >= 1700) and (birth_time < 1900):
hour_animal = "ROOSTER"
elif (birth_time >= 1900) and (birth_time < 2100):
hour_animal = "DOG"
elif (birth_time >= 2100) and (birth_time < 2300):
hour_animal = "BOAR"
关于如何简化这方面的任何想法?
谢谢!