Cannot Figure out whats wrong with this code [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)
I have been working on this, and I am not sure why it returns "none" instead of the variable I set it to return,
Any help is helpful, thanks if anyone could help because I cannot figure it out myself even though it is most likely extremely simple.
python
|
show 7 more comments
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)
I have been working on this, and I am not sure why it returns "none" instead of the variable I set it to return,
Any help is helpful, thanks if anyone could help because I cannot figure it out myself even though it is most likely extremely simple.
python
We can't even run the code without literally typing it in to see the error, imagine how stumped we are.
– timgeb
Nov 16 '18 at 16:19
Add the code, not a link with a screenshot
– Luis Cabrera Benito
Nov 16 '18 at 16:20
@timgeb I run it on Repl, it gives this output prntscr.com/lj80jw, it should be outputting the number you choose in the input.
– ThePatchWorkHoax
Nov 16 '18 at 16:20
Sorry I was not being explicit: post the code as text, not as a picture, please.
– timgeb
Nov 16 '18 at 16:21
Your code has three conditionals and only two of them return.
– SilverSlash
Nov 16 '18 at 16:21
|
show 7 more comments
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)
I have been working on this, and I am not sure why it returns "none" instead of the variable I set it to return,
Any help is helpful, thanks if anyone could help because I cannot figure it out myself even though it is most likely extremely simple.
python
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)
I have been working on this, and I am not sure why it returns "none" instead of the variable I set it to return,
Any help is helpful, thanks if anyone could help because I cannot figure it out myself even though it is most likely extremely simple.
python
python
edited Nov 16 '18 at 16:22
ThePatchWorkHoax
asked Nov 16 '18 at 16:18
ThePatchWorkHoaxThePatchWorkHoax
196
196
We can't even run the code without literally typing it in to see the error, imagine how stumped we are.
– timgeb
Nov 16 '18 at 16:19
Add the code, not a link with a screenshot
– Luis Cabrera Benito
Nov 16 '18 at 16:20
@timgeb I run it on Repl, it gives this output prntscr.com/lj80jw, it should be outputting the number you choose in the input.
– ThePatchWorkHoax
Nov 16 '18 at 16:20
Sorry I was not being explicit: post the code as text, not as a picture, please.
– timgeb
Nov 16 '18 at 16:21
Your code has three conditionals and only two of them return.
– SilverSlash
Nov 16 '18 at 16:21
|
show 7 more comments
We can't even run the code without literally typing it in to see the error, imagine how stumped we are.
– timgeb
Nov 16 '18 at 16:19
Add the code, not a link with a screenshot
– Luis Cabrera Benito
Nov 16 '18 at 16:20
@timgeb I run it on Repl, it gives this output prntscr.com/lj80jw, it should be outputting the number you choose in the input.
– ThePatchWorkHoax
Nov 16 '18 at 16:20
Sorry I was not being explicit: post the code as text, not as a picture, please.
– timgeb
Nov 16 '18 at 16:21
Your code has three conditionals and only two of them return.
– SilverSlash
Nov 16 '18 at 16:21
We can't even run the code without literally typing it in to see the error, imagine how stumped we are.
– timgeb
Nov 16 '18 at 16:19
We can't even run the code without literally typing it in to see the error, imagine how stumped we are.
– timgeb
Nov 16 '18 at 16:19
Add the code, not a link with a screenshot
– Luis Cabrera Benito
Nov 16 '18 at 16:20
Add the code, not a link with a screenshot
– Luis Cabrera Benito
Nov 16 '18 at 16:20
@timgeb I run it on Repl, it gives this output prntscr.com/lj80jw, it should be outputting the number you choose in the input.
– ThePatchWorkHoax
Nov 16 '18 at 16:20
@timgeb I run it on Repl, it gives this output prntscr.com/lj80jw, it should be outputting the number you choose in the input.
– ThePatchWorkHoax
Nov 16 '18 at 16:20
Sorry I was not being explicit: post the code as text, not as a picture, please.
– timgeb
Nov 16 '18 at 16:21
Sorry I was not being explicit: post the code as text, not as a picture, please.
– timgeb
Nov 16 '18 at 16:21
Your code has three conditionals and only two of them return.
– SilverSlash
Nov 16 '18 at 16:21
Your code has three conditionals and only two of them return.
– SilverSlash
Nov 16 '18 at 16:21
|
show 7 more comments
1 Answer
1
active
oldest
votes
It's because you aren't actually returning any value.
Your N_C_restart_input
function returns a value, but your N_C
function never does. Your last line in the N_C
function should probably look like this:
return N_C_restart_input()
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341720%2fcannot-figure-out-whats-wrong-with-this-code-python-3x%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's because you aren't actually returning any value.
Your N_C_restart_input
function returns a value, but your N_C
function never does. Your last line in the N_C
function should probably look like this:
return N_C_restart_input()
add a comment |
It's because you aren't actually returning any value.
Your N_C_restart_input
function returns a value, but your N_C
function never does. Your last line in the N_C
function should probably look like this:
return N_C_restart_input()
add a comment |
It's because you aren't actually returning any value.
Your N_C_restart_input
function returns a value, but your N_C
function never does. Your last line in the N_C
function should probably look like this:
return N_C_restart_input()
It's because you aren't actually returning any value.
Your N_C_restart_input
function returns a value, but your N_C
function never does. Your last line in the N_C
function should probably look like this:
return N_C_restart_input()
answered Nov 16 '18 at 16:23
Caleb H.Caleb H.
36311
36311
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341720%2fcannot-figure-out-whats-wrong-with-this-code-python-3x%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
We can't even run the code without literally typing it in to see the error, imagine how stumped we are.
– timgeb
Nov 16 '18 at 16:19
Add the code, not a link with a screenshot
– Luis Cabrera Benito
Nov 16 '18 at 16:20
@timgeb I run it on Repl, it gives this output prntscr.com/lj80jw, it should be outputting the number you choose in the input.
– ThePatchWorkHoax
Nov 16 '18 at 16:20
Sorry I was not being explicit: post the code as text, not as a picture, please.
– timgeb
Nov 16 '18 at 16:21
Your code has three conditionals and only two of them return.
– SilverSlash
Nov 16 '18 at 16:21