Apr-29-2021, 10:44 AM
If you are trying to print jp outside of the function (def), it won't work because jp has gone out of scope.
if you return the value, you will be able to print the values
Example:
if you return the value, you will be able to print the values
Example:
>>> import random >>> def toto(): ... jp = [] ... for i in range(4): ... jp.append(random.randint(1,10)) ... return(jp) ... >>> jp = toto() >>> print(*jp) 3 1 5 7 >>> print(jp[0]) 3 >>>