回答編集履歴
1
質問が変更になったので追記
answer
CHANGED
@@ -1,3 +1,11 @@
|
|
1
1
|
A関数実行後に条件文書いてreturnすればいいのでは。
|
2
2
|
> return を使うと、式リスト (または None) を戻り値として、現在の関数呼び出しから抜け出します。
|
3
|
-
[7. 単純文 (simple statement) — Python 3.6.1 ドキュメント](https://docs.python.jp/3/reference/simple_stmts.html?highlight=return#the-return-statement)
|
3
|
+
[7. 単純文 (simple statement) — Python 3.6.1 ドキュメント](https://docs.python.jp/3/reference/simple_stmts.html?highlight=return#the-return-statement)
|
4
|
+
|
5
|
+
##### 質問が変更になったので追記
|
6
|
+
> Bメソッドでlen(array) が0なのでエラー
|
7
|
+
|
8
|
+
↑これと↓には矛盾がありますよね。
|
9
|
+
> メソッドBを実行した後にwhile文を抜け一番下のprint文でメソッドBの結果の配列を出力
|
10
|
+
|
11
|
+
そうしたいなら、len(array) が0の時にエラーになるB関数の仕様が間違っているかと思います。
|