Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法找出此代码的错误[python 3x]_Python - Fatal编程技术网

无法找出此代码的错误[python 3x]

无法找出此代码的错误[python 3x],python,Python,我一直在研究这个,我不知道为什么它返回“none”而不是我设置它返回的变量 任何帮助都是有帮助的,如果有人能帮助我,我会非常感谢,因为我自己无法理解,即使它非常简单。这是因为您实际上没有返回任何值。 N\u C\u restart\u input函数返回一个值,但N\u C函数从不返回。N_C函数中的最后一行可能如下所示: return N\u C\u restart\u input()我们甚至无法运行代码而不直接键入它来查看错误,想象一下我们有多难堪。添加代码,而不是带有screenshot@

我一直在研究这个,我不知道为什么它返回“none”而不是我设置它返回的变量


任何帮助都是有帮助的,如果有人能帮助我,我会非常感谢,因为我自己无法理解,即使它非常简单。

这是因为您实际上没有返回任何值。
N\u C\u restart\u input
函数返回一个值,但
N\u C
函数从不返回。
N_C
函数中的最后一行可能如下所示:


return N\u C\u restart\u input()

我们甚至无法运行代码而不直接键入它来查看错误,想象一下我们有多难堪。添加代码,而不是带有screenshot@timgeb我在Repl上运行它,它给出这个输出,它应该输出您在输入中选择的数字。抱歉,我没有明确说明:请将代码作为文本而不是图片发布。您的代码有三个条件,其中只有两个返回。
def N_C(question,choices):
  N_C_choices_to_num = []
  N_C_choice_count_max = len(choices)
  N_C_choice_count_min = N_C_choice_count_max - N_C_choice_count_max
  print(question)
  for i in range (N_C_choice_count_min, N_C_choice_count_max):
    print(N_C_choice_count_min+i+1,".", choices[i])
    N_C_choices_to_num.append(N_C_choice_count_min+i+1)
  def N_C_restart_input():
    N_C_choices_num = input(">>>")
    if str(N_C_choices_num) in str(N_C_choices_to_num):
      return "something"
    elif str(N_C_choices_num) not in str(N_C_choices_to_num):
      N_C_restart_input()
    else:
      return(N_C_choices_num)
  N_C_restart_input()



answer = N_C("Hey Bro, how are you?",["Fine","Dead","Okay..."])
print(answer)