回答編集履歴

3

コード修正

2018/11/09 15:41

投稿

can110
can110

スコア38266

test CHANGED
@@ -5,8 +5,6 @@
5
5
  choice2 = input("please choose the number: ")
6
6
 
7
7
  choice3 = int(choice2)
8
-
9
- menuList(choice3) # 関数を呼び出す!
10
8
 
11
9
  def menuList(choice3):
12
10
 
@@ -16,4 +14,6 @@
16
14
 
17
15
  # 略
18
16
 
17
+ menuList(choice3) # 関数を呼び出す!
18
+
19
19
  ```

2

全面修正

2018/11/09 15:41

投稿

can110
can110

スコア38266

test CHANGED
@@ -1,19 +1,19 @@
1
- (タートル)動作未検証ですが、以下のように最後に`return choice3`ばよのではないでしょうか?
1
+ `menuList`関数が呼ばいないようす。
2
2
 
3
3
  ```Python
4
4
 
5
+ choice2 = input("please choose the number: ")
6
+
7
+ choice3 = int(choice2)
8
+
9
+ menuList(choice3) # 関数を呼び出す!
10
+
5
11
  def menuList(choice3):
6
12
 
7
- #
13
+ if choice3 == 0:
8
14
 
9
- return choice3 # とりあえず渡された値をそのまま返す
15
+ print("bad input")
10
16
 
11
-
12
-
13
- ret = menuList(0)
14
-
15
- # (ターミナル上にbad inputと表示される)
16
-
17
- print(ret) # 0
17
+ #
18
18
 
19
19
  ```

1

質問修正にあわせ修正

2018/11/09 15:40

投稿

can110
can110

スコア38266

test CHANGED
@@ -4,18 +4,16 @@
4
4
 
5
5
  def menuList(choice3):
6
6
 
7
- choice2 = input("please choose the number: ")
8
-
9
- choice3 = int(choice2)
10
-
11
7
  # 略
12
8
 
13
- return choice3 # 選択し番号を返す
9
+ return choice3 # とりあえず渡されそのまま返す
14
10
 
15
11
 
16
12
 
17
- ret = menuList(12345) # 渡した値は無視されるが…
13
+ ret = menuList(0)
18
14
 
15
+ # (ターミナル上にbad inputと表示される)
16
+
19
- print(ret) # 選択された番号
17
+ print(ret) # 0
20
18
 
21
19
  ```