# Python CodeRecipe|next()の使い方

HomeFunctions

# next()の例1

Create an iterator, and print the items one by one:

    mylist = iter(["apple", "banana", "cherry"])x = 
    next(mylist)print(x)x = next(mylist)print(x)x = next(mylist)
    print(x)

# next()の定義及び使い方

next()関数は イテレータの次の項目。 デフォルトの戻り値を追加して、反復可能パラメータがに達した場合に返すことができます。 終了します。

# next()の構文

    next(iterable, default)

# next()の引数

反復可能な 必須。反復可能なオブジェクト。

デフォルト オプション。反復可能ながに達した場合に返すデフォルト値end.

# next()の例2

Return a default value when the iterable has reached to its end:

    mylist = iter(["apple", "banana", "cherry"])x = 
    next(mylist, "orange")print(x)x = next(mylist, "orange")print(x)x = 
    next(mylist, "orange")print(x)x = next(mylist, "orange")print(x)

HomeFunctions