Differences between revisions 2 and 3
Revision 2 as of 2018-09-28 14:20:27
Size: 860
Comment:
Revision 3 as of 2018-09-28 14:26:42
Size: 884
Comment:
Deletions are marked like this. Additions are marked like this.
Line 50: Line 50:
    print( "END" )     print( "無事,終了しました" )


制御構造:反復:While

  • ~のあいだ繰り返す(while, else)
  • 文法

   1 while expression:
   2     suite...
   3 [else:
   4     suite...]
  • while は「~のあいだ」を意味します

   1 n = 0
   2 while n < 10:
   3     print( n )
   4     n += 1

   1 for n in range(10):
   2     print( n )
  • else がある場合は,ループの最後に else節を実行する
    • breakした場合は...

   1 n = 0
   2 while n < 10:
   3     print( n )
   4     n += 1
   5 else:
   6     print( "無事,終了しました" )

SoftEng: Python/Lang/ControlStructure/Loop/WhileStatement/Contents (last edited 2018-10-04 05:30:33 by TadashiIijima)