I just moved to spyder for Python and the return function doesn't seem to work:
def test():return 2
test()
The IPython console is empty. If I use print instead of return it works fine. Any idea?
I use python 3.7 with Spyder 4.1.5
Thanks in advance!
The editor is handling your code as a normal python script which means statements ala
test()
don't print their result. Instead you will need to do something with the value you are returning E.g. assign it to a variable or print it.
That you get the result of something displayed immediately is a special function of the python console and not normal python behaviour.
To actually print the result you have to call print(test())
so try this:
def test():
return 2
enter >>press enter
print(test()>>press enter