ATOM function return value is wrong

413 views Asked by At

I have the following code:

def do_math(a, b, kind = 'add' ):  

    if (kind=='add'):  
       return a+b  

    else:
       return a-b

do_math(1, 2)

I used this page, in order to convert ATOM into the interactive mode:

https://github.com/foreshadow/atom-python-run/wiki/12-How-Do-I-Use-atom-python-run#interactive-mode

But it returns 1, not 3 as expected.

Here is a screenshot:

Atom View, look at the returned value at the bottom...

How should I handle/solve this problem, so the returned value will be 3?


1

There are 1 answers

2
TerryA On BEST ANSWER

I don’t use Atom but I’m going to infer that when it says file:1at the bottom there it’s actually referring to the first line of the file. The tick means that the code probably compiles.

You need to add a print() around your Function call so that the result can be printed to the console.