# Python CodeRecipe|elseの使い方
❮ Home ❮ Python Keywords
# elseの例1
Print "YES" if x larger than 3, otherwise print "NO":
x = 2if x > 3:
print("YES")else: print("NO")
# elseの定義及び使い方
else関数は、条件付きで使用されます。 ステートメント(if文)を使用して、条件が いいえ。 else関数は、 試してみてください...。ただし、ブロックの場合は次の例を参照してください。
# elseの例2
Use the else keyword in a try...except block to define what to do if no
errors were raised:
x = 5try: x > 10except:
print("Something went wrong")else:
print("The 'Try' code was executed without raising any errors!")
Related Pages The if keyword. The elif keyword. Read more about conditional statements in our Python Conditions Tutorial.
❮ Home ❮ Python Keywords