无法弄清楚这个代码[python 3x]有什么问题


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)

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

任何帮助都是有帮助的,如果有人能帮忙的话,谢谢你,因为我自己也弄不明白,尽管这很可能非常简单。

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

return N_C_restart_input()

最新更新