Oct-01-2019, 01:09 AM
First, you can't use multiple return statements the way you are trying to. As soon as a return statement is processed, the function stops processing code. If you need to return two values, return them as a tuple:
You define check_answer with no parameters, but then you are calling it with four parameters:
I think you want to rename what you have as check_answer as check_all, and then write another function check_answer that actually does the check.
You keep storing new answers to output, but that over writes the old ones. So at the end, you are just returning the last answer. Maybe you want that to be a list of answers, which you append each answer to?
You do this alot:
def Main(): int1 = int(input("Please enter a integer: ")) int2 = int(input("Please enter a second integer:")) return int1, int2Although you never call main, so I guess that's not a problem?
You define check_answer with no parameters, but then you are calling it with four parameters:
answer1 = check_answer(1, 2, 3, "+")
. And even if the parameters are straightened out, that's not going to work. You'll call check_answer, it will get to line 11 and call check_answer again, which will get to line 11 and call check_answer again, which will get to line 11 and call check_answer again, and so on until you get a recursion error.I think you want to rename what you have as check_answer as check_all, and then write another function check_answer that actually does the check.
You keep storing new answers to output, but that over writes the old ones. So at the end, you are just returning the last answer. Maybe you want that to be a list of answers, which you append each answer to?
You do this alot:
if answer2 == -1: print("True") if answer2 != -1: print("False")Since the second test is a contradiction of the first test, you can just use an else statement:
if answer2 == -1: print("True") else: print("False")
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures