0

だから、私は以下のこの機能を持っています:

def remove_all(lst):
    i = 0
    while i < 10:
        try:
            print('Removing... ')
            print(int(lst.pop()) + 10)
            print("Removed successfully.")

        # As soon as an IndexError is raised, jump to the following block of code...        
        except IndexError as err: 
            # if you encounter an indexerror, do the following:
            print("Uh oh! Problems.")
            return

        #As soon as a Value error is raised, jump here.
        except ValueError as err:
            print("Not a number")

        i = i + 1

リターンは何をしますか?リターンの後に値がないので、NoneかTrueか?そして、値が何もない場合、そこに戻り値があるという点は何ですか?

ありがとう!

4

4 に答える 4

7

戻り値はNone.

このコンテキストでは、関数は値を返しません。のポイントは、return実行を停止することです

于 2013-08-14T05:30:02.703 に答える
0

return ステートメントは一種の制御フローとして使用できます。関数の途中に 1 つ (または複数) の return ステートメントを配置することで、関数を終了/停止できます。

于 2013-08-14T05:29:53.400 に答える