0
このコードを実行するたびに、常にelseステートメントに進みます。互換性のある標識の条件が満たされている場合、出力は常に互換性がありません。私は間違って何をしていますか? signとsign2は、黄道帯の記号の変数です。私は2つの兆候がお互いに互換性があるかどうかを確認するために十二支の要素を使用しています。ifステートメントの2つの条件を試す
def zodiacCompatibility(sign, sign2):
fire = ["Aries, Leo, Sagittarius"]
earth = ["Capricorn, Taurus, Virgo"]
water = ["Pisces, Cancer, Scorpio"]
air = ["Gemini, Aquarius, Libra"]
if (sign in fire and sign2 in fire):
result = ("The two signs are compatible")
if (sign in earth and sign2 in earth):
result = ("The two signs are compatible")
if (sign in air and sign2 in air):
result = ("The two signs are compatible")
if (sign in water and sign2 in water):
result = ("The two signs are compatible")
if (sign in fire and sign2 in air):
result = ("The two signs are compatible")
if (sign in water and sign2 in earth):
result = ("The two signs are compatible")
if (sign in air and sign2 in fire):
result = ("The two signs are compatible")
if (sign in earth and sign2 in water):
result = ("The two signs are compatible")
else:
result = ("The two signs are not compatible")
finalResult = zodiacCompatibility(sign, sign2)
プリント(finalResult)
私はエリフで条件を1つ、またはその中にある場合は入れ子にすることに決めました。出来た。どうもありがとう。 –
しかし、なぜ "と"は動作しませんでしたか?満たされる必要がある2つの条件がある場合には、 "と"は使用されません。 –
「と」条件の両方またはいずれかが実行されます文の中でどんな満たされている場合は、条件付きで作業を行います。 – PeskyPotato