2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

while文

Last updated at Posted at 2019-11-05

はじめに

この記事ではwhile文の使い方を簡単にまとめています。

while文の作成方法

while 条件式:
     条件式が真の時に実行する文

と書きます。

条件式が真となった時、
whileブロックの中の式が
順に実行されて行きます。

while文は、
条件式が真の間、
無限に処理が繰り返されます。

なので、
必ず繰り返し処理が終了するよう
中身の式を考えましょう!

while.else

while.elseを使うと、
条件式が偽になった時に施行する
式が書けます。

while 条件式:
      条件式が真の時に実行する文
else:
      条件式が偽の時に実行する文 

:を忘れないようにしましょう。

参照

2
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?