how to get the ordinal number in list
luofeiyu
elearn2014 at gmail.com
Sat Aug 9 13:35:58 EDT 2014
>>> x=["x1","x3","x7","x5","x3"]
>>> x.index("x3")
1
if i want the result of 1 and 4 ?
On 8/8/2014 7:25 PM, Larry Martell wrote:
> On Sat, Aug 9, 2014 at 1:22 PM, luofeiyu <elearn2014 at gmail.com> wrote:
>>>>> x=["x1","x3","x7","x5"]
>>>>> y="x3"
>> how can i get the ordinal number by some codes?
>>
>> for id ,value in enumerate(x):
>> if y==value : print(id)
>>
>> Is more simple way to do that?
> print x.index(y)
More information about the Python-list
mailing list