vendredi 14 février 2020

finding astrology signs according to your month and date, simpler way to do it? instead of 12 if function

if month == 12:
    if 0 < date < 23:
        return 'SAG'
    if 23 <= date < 32:
        return 'CAP'
if month == 1:
    if 0 < date < 21:
        return 'CAP'
    if 21 <= date < 32:
        return 'AQU'
if month == 2:
    if 0 < date < 20:
        return 'AQU'
    if 20 <= date < 30:
        return 'PIS'
if month == 3:
    if 0 < date < 21:
            return 'PIS'
    if 21 <= date < 32:
            return 'ARI'

I am looking for a simpler and more effective way of completing my function of finding astrological sign according to month and date, is there a more effective method or is using 12 if loops a must?

Aucun commentaire:

Enregistrer un commentaire