There are several ambiguities in the question that directly affect the solution.
The first is that we can not know for sure if the ab
value must be the concatenation of the a
and b
values, leaving 1020, or if ab
must be the product between a
and b
, getting 200. Whatever the correct form, your code is wrong.
-
If concatenation, you need to convert to string and use the +
: str(a)+str(b)
; or in Python 3.6+ use f-string : f'{a}{b}'
;
-
If multiplying, you need to use the *
operator: a*b
;
I talked a little bit about the Python operators in Which equivalent operator is different in Python?
The second is that you put (ab)+(bc)+(cd)+(de)/e
. This means mathematically that only the de
value will be divided by e
, which would only result in d
, if e
is non-zero.
How do I believe the correct one would be:
You will need to put all of your denominator in parentheses: ((ab)+(bc)+(cd)+(de))/e
.
By making these fixes, you'll probably get the expected result.