just extract b[i][0:1] and b[i][1:2] out of for loop

but i depend on for loop

def node(mmm, A, B): 
 H2 = [MM[mmm][A+B] for i in range(len(b))] 
 return H2 
 
node(5, b[i][0:1], b[i][1:2]) 

it is not convenient to disclose in detail
just expect to discuss from the view of programming

On Wednesday, June 8, 2016 at 4:56:56 PM UTC+8, Steven D'Aprano wrote:
> On Wednesday 08 June 2016 17:31, meInvent bbird wrote:
> 
> > b = [str(i)+str(j)+str(k) for i in range(m) for j in range(m) for k in
> > range(m)]
> > b[21][0:1]+b[21][1:2]
> > b[21][1:2]+b[21][2:3]
> > b[21][0:1]+b[21][2:3]
> > 
> > 
> > originally,
> > 
> > mmm = 5
> > H2 = [MM[mmm][b[i][0:1]+b[i][1:2]] for i in range(len(b))]
> 
> This is a mess. I don't understand what you are trying to do. You have these 
> variable names that don't mean anything, like "b" and "H2", and others which 
> aren't defined, like MM. I don't understand what you are trying to 
> accomplish, 
> or the purpose of your code.
> 
> 
> > how to extract b[i][0:1] and b[i][1:2] as parameters?
> 
> I don't understand the question.
> 
> 
> > def node(mmm, b[i][0:1], b[i][1:2]):
> >  H2 = [MM[mmm][A+B] for i in range(len(b))]
> >  return H2
> > 
> > node(5, b[i][0:1], b[i][1:2])
> 
> Explain what node() is supposed to do, in English. Don't write any code yet. 
> What is its purpose? What does it return? What arguments does it need to take 
> in order to perform its purpose?
> 
> 
> -- 
> Steve
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to