0
Defining a result
Trying to define a result to an equation in python. Error on line one. What’s going on? https://code.sololearn.com/cjJ2Cgm0P38k/?ref=app
1 Resposta
+ 1
You're using three undefined variables in the first line (result, x and y). The first thing you should do is change ... = result to result = ... . But x and y are still undefined, so python won't know what to do with the whole expression and it will result in an error.
(x+y or x*y) is a boolean expression, I don't know if this is really what you want. It will be either True (=1) or False (=0).
The function print_result_twice looks good, however it doesn't return anything (that's okay, but you can't use the calculated value for anything else after you called the function).
You could do something like this:
def print_result_twice(x, y):
return x*y
result = print_result_twice(5, 8)
if result == 40:
# do something
else:
# do something else
Btw, your name means roe (deer) field in German. Aww 🦌