2 ms·
Instead of def sum_double(a, b): # Store the sum in a local variable sum = a + b # Double it if a and b are the same if a =
by Luyt 16y ago
Instead of
def sum_double(a, b):
# Store the sum in a local variable
sum = a + b
# Double it if a and b are the same
if a == b:
sum = sum * 2
return sum
I wrote:
def sum_double(a, b):
return (a+b)*2 if a==b else a+b
My solution was accepted. Apparently the site evaluates the python program. This is much better than some online C++ test I once took, where my entry had to match perfectly a pre-canned solution letter by letter (it would even balk on differences in whitespace).