Hi,
I'm looking for a pythonic way to translate this short Ruby code :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=t.index {|x| x=t[0] : i+=1
... not pythonic I think...
Or :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=[j for j in range(len(t)) if t[j]http://mail.python.org/mailman/listinfo/python-list
On 11/02/2011 22:24, LL.Snark wrote:
Hi,
I'm looking for a pythonic way to translate this short Ruby code :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=t.index {|x| x=t[0] : i+=1
... not pythonic I think...
Or :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=[j for j in range(len(t)) if t[j]
Thx for your answers.
May
On 12/02/2011 04:49, Terry Reedy wrote:
On 2/11/2011 4:24 PM, LL.Snark wrote:
Hi,
I'm looking for a pythonic way to translate this short Ruby code :
t=[6,7,8,6,7,9,8,4,3,6,7]
i=t.index {|x| x
What does Ruby do if there is no such element?
For Python, the answer should be either No