+ 2
How do I continue a def after calling a def inside the first?
I've nested a def inside a def and it works, but the first def doesn't continue afterwards. How do I make it continue where it left off after calling the second def? this is an example I've typed on since the original was typed on a computer https://code.sololearn.com/cOPNlS1Gi212/?ref=app
16 Respuestas
+ 2
Why die you nest it? Why not make two separate defs.
+ 2
..well.. shit hahaha
thanks for trying to help though
I at least learned something
+ 2
you know what... I'm a moron. haha
on the computer def Response and variable Response were both capitalized. I thought it didn't matter since one was a variable and the other was a def.
I've learn so much hahahaha
thanks a ton dude!
epiphany from that last answer of yours 😂
+ 1
I did, I'm currently typing an example since I did the original on a computer.
But the 2 defs are orignally seperate. the second one calls the first one inside of it though as part of its events. I'll post the example soon
+ 1
wait, what do you mean?
+ 1
where at? I'm trying to be able to use this response def in multiple defs.. so the response variable needs to be cleared every time
+ 1
for some reason that works on solo, but not on my computer... hahaha I'm running 3.6.2 if that matters
+ 1
it says
(response=Response ()
local variable 'response' referenced before assignment)
I am able to input before adding that but it won't continue the outer def after the nested def completes
+ 1
It is as if your IDE was case insensitive
0
a block is define by its indentation, so the code of a def inside a def is more indented than the code of the def
0
you did not save the return value of Reponse in Input :)
0
you should do :
response = Reponse()
0
#It is exactly what the return statement is here for !
def Response():
response=""
while response!='Y' and response != 'N':
response=input('Y or N?').upper()
print('def complete')
return response
def Intro():
print('can you hear me?')
reponse = Response()
if response=='Y':
print('good')
if response=='N':
print('very funny')
0
What is the error message on your computer ?
0
I do not know what is the cause of that but it is not supposed to happen ! :o
0
Errors that make you feel like a moron happen sooo much, I know that feeling 😂
Glad to have been of help to you :)