Михаил обнови решението на 10.03.2015 21:01 (преди над 9 години)
+WESTERN_SIGNS = {(3, range(21, 32)): "aries",
+ (4, range(1, 21)): "aries",
+ (4, range(21, 31)): "taurus",
+ (5, range(1, 21)): "taurus",
+ (5, range(21, 32)): "gemini",
+ (6, range(1, 21)): "gemini",
+ (6, range(21, 31)): "cancer",
+ (7, range(1, 23)): "cancer",
+ (7, range(23, 32)): "leo",
+ (8, range(1, 23)): "leo",
+ (8, range(23, 32)): "virgo",
+ (9, range(1, 23)): "virgo",
+ (9, range(23, 31)): "libra",
+ (10, range(1, 23)): "libra",
+ (10, range(23, 32)): "scorpio",
+ (11, range(1, 22)): "scorpio",
+ (11, range(22, 31)): "sagittarius",
+ (12, range(1, 22)): "sagittarius",
+ (12, range(22, 32)): "capricorn",
+ (1, range(1, 21)): "capricorn",
+ (1, range(21, 32)): "aquarius",
+ (2, range(1, 19)): "aquarius",
+ (2, range(19, 30)): "pisces",
+ (3, range(1, 21)): "pisces"}
+
+CHINESE_SIGNS = {0: "rat",
+ 1: "ox",
+ 2: "tiger",
+ 3: "rabbit",
+ 4: "dragon",
+ 5: "snake",
+ 6: "horse",
+ 7: "sheep",
+ 8: "monkey",
+ 9: "rooster",
+ 10: "dog",
+ 11: "pig"}
+
+
+def interpret_western_sign(day, month):
+ for (m, d), sign in WESTERN_SIGNS.items():
+ if month == m and day in d:
+ return sign
+
+
+def interpret_chinese_sign(year):
+ sign = (year - 4) % 12
+ return CHINESE_SIGNS[sign]
+
+
+def interpret_both_signs(day, month, year):
+ return (interpret_western_sign(day, month),
+ interpret_chinese_sign(year))
Помисли коя колекция е по-добра идея от речник за CHINESE_SIGNS
:)