Birth_date is an integer between 1 and 2359. Every animal is also part of a list. I want to convert the birth date to the list index but I'm not sure how.
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"
Any thoughts on how this could be simplified?
Thanks!
If your list starts with
RAT
, the index should be(birth_time + 100) // 200 % 12
.But better verify it: