if...elif...else

□未翻訳

□翻訳中

□翻訳完了(細田謙二)

■レビュー(Omi Chiba)

if...elif...else

Pythonにおける条件文の使用は直感的です:

The use of conditionals in Python is intuitive:

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

>>> for i in range(3):

>>> if i == 0:

>>> print 'zero'

>>> elif i == 1:

>>> print 'one'

>>> else:

>>> print 'other'

zero

one

other

"elifは""else if"の意味です。elifとelse句はどちらも省略可能です。elifは何回も利用可能ですが、elseは一度だけです。 複雑な条件文はnot、and、orの演算子を利用し作成することができます。

"elif" means "else if". Both elif and else clauses are optional. There can be more than oneelif but only one else statement. Complex conditions can be created using the not, and and oroperators.

1.

2.

3.

>>> for i in range(3):

>>> if i == 0 or (i == 1 and i + 1 == 2):

>>> print '0 or 1'