1分で学ぶPython|forの使い方

Home Python Keywords

forの例1

Print each number from 1 to 8:

    for x in range(1, 9):  
    print(x)

forの定義及び使い方

for関数は、 forループ。 リストやタプルなどのシーケンスを反復するために使用できます。

forの例2

Loop through all items in a list:

    fruits = ["apple", "banana", "cherry"]for x in fruits:  print(x)

Related Pages Use the break keyword to break out of a loop. Use the continue keyword to end the current iteration, but continue with the next. Read more about for loops in our Python For Loops Tutorial.

Home Python Keywords

Last Updated: 7/27/2019, 11:23:37 AM