hi all,
when i am running a Python script that i made, i get a list as a result
( i do not know the number of items stored in that list )
HOW can i return each element of the list
and store in an array defined in a unix script ?
thanx
hi all,
when i am running a Python script that i made, i get a list as a result
( i do not know the number of items stored in that list )
HOW can i return each element of the list
and store in an array defined in a unix script ?
thanx
I don't know what you mean by:
store in an array defined in a unix script ?
-but, to return each element:
# since you used 'return' I assume you want a function
# l1 is a an empty list
>>> l1=[]
>>> for x in range(3):
l1.append(raw_input("..."))
...1
...2
...3
# In the for loop, instead of 3, use any number of you choice
>>> n=0
>>> def retl1():
return l1[n]
# The return statement returns the value as you wanted it
>>> for x in range(3):
element=retl1()
n+=1
# Since you want to return 'each element', use a for loop to iterate
# through the elements
>>>
thank you a lot
I don't know what you mean by:
-but, to return each element:# since you used 'return' I assume you want a function # l1 is a an empty list >>> l1=[] >>> for x in range(3): l1.append(raw_input("...")) ...1 ...2 ...3 # In the for loop, instead of 3, use any number of you choice >>> n=0 >>> def retl1(): return l1[n] # The return statement returns the value as you wanted it >>> for x in range(3): element=retl1() n+=1 # Since you want to return 'each element', use a for loop to iterate # through the elements >>>
Very well explained. Good job!
Very well explained. Good job!
Thanks gmilby
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.