If I have a function in Python like this that calculates the sum of the elements in a list:
def sum_it(_arr):
if len(_arr) <= 1:
raise ValueError("The input must be a list of length > 1")
_init = 0
for i in range(len(_arr)):
_init += _arr[i]
_sum = _init
return _sum
No I call the function like this and I execute it.
result = sum_it([1, 2, 3, 4])
My problem is: if I do not save the result
into a text file or I do not print result
, where can I access it? Do I have to re-execute the code in order to access to the output?
I mean, in MATALB for example, when I have something like this and I run it, I will have a workspace where all my variables and outputs are stored. Is it possible to do this in Python?
I hope I am not asking wrong question.