21 Answers
+ 4
No... Try, Catch and Finally have a specific architecture and dynamic...
+ 3
Short answer: no
+ 2
def yes_no():
num = int(input(""))
if num in range(0, 100000000)
return remainder()
if remainder() == 0
print ("This is an even number.")
else
print ("This is an odd number.")
if num not in range(0, 1000000000)
print ("Number is too high or too low")
def remainder():
remainder = x % 2
print(yes_no())
I get a syntax error which refers to the range statement
+ 1
You cannot use finally as it basically works with try and except blocks. For eg. The principal of if and else statements!
+ 1
The thing I saw was that you called the second function in the first function while second function is not defined
0
Alrighty. Sucks that I can't, but eh. I'll figure out another way to what I'm trying to do
0
just print whatever you wanna print after calling the method/function
0
The problem is that I'm trying to get the code to return a second defined function, and then see if that code is true or not, then print a line if it is true.
0
in ur first function call the second function, check if true, print, return function one
0
can you post it as code?
0
Ou cant have an elif after an else statement. also remove the ':' after elif. switch the elif and else around and it works
0
It works if I do that, but it also still has "None" in the output. Plus, if you do a negative number the output gives a RunTime error
0
the none comes because you are printing whatever yes_no() returns, which is none
0
you get an runtime error because you are comparing your variable 'remainder' to 0 but this variable has never been created
0
Not sure why the return for yes_no() is none, but that at least explains why I'm getting None.
As for the second part, is it doing that because if remainder doesn't go into effect, the return still runs but it fails because there's no value?
0
you never return anything therefore its none
you create remainder in an if-block which doesnt execute if u chose a negativ number, so if your number is negativ you have no variable called remaineder. you still try to access it tho
0
No.
0
šš½
0
Never. whatever is writtin In local defining funcion, any statement, including finally doesn't work afer return statement. Thus, THE ANSWER IS NO.