Consider the following function:
def Func(x):
Code
return List_A, List_B, number_C
I want to store one of the returned values as some variable "x" so how can I go about doing this? For example, I want to store List_B as x
I tried
x=Func[1]
Detailed explanation:
n=int(input("blablabla"))
def Func(n)
l_e=[]
for i in range (1,n):
if i%2==2:
l_e.append(i)
l_o=[]
for i in range (1,n):
if i%2>2:
l_o.append(i)
l=len(l_0) len(l_e)
return l_o, L_e, l
let's say I want to store the second item returned as a variable, how can I do this. I tried x=Func[1]
, and x=Func()[1]
but to no avail.
CodePudding user response:
The following works: x = Func()[1]
. The parentheses call the function, then the square brackets pick the item you want out of the returned tuple.