443,275 Members | 1,745 Online
Need help? Post your question and get tips & solutions from a community of 443,275 IT Pros & Developers. It's quick & easy.

 P: n/a Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! Oct 17 '06 #1
5 Replies

 P: n/a pr*************@hotmail.com wrote: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! >>a = [[1,1], [2,2]]map( lambda x: x + ['='], a ) [[1, 1, '='], [2, 2, '=']] >>> Oct 17 '06 #2

 P: n/a pr*************@hotmail.com wrote: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! To copy a list use: b=a[:] -Larry Oct 17 '06 #3

 P: n/a pr*************@hotmail.com wrote: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? b = [item + ['='] for item in a] -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in 'o****@xiludom.gro'.split('@')])" Oct 17 '06 #4

 P: n/a pr*************@hotmail.com wrote in news:1161102973.920895.141500 @i42g2000cwa.googlegroups.com: Hello: Variable 'a' has the next values: [[1,1],[2,2]] and I want to take a to b as: [[1,1,'='],[2,2,'=']] How can I do this with only one line of instruction? Thanks!! b = [[x,y,'='] for (x,y) in a] -- rzed Oct 17 '06 #5

 P: n/a Larry Bates wrote: pr*************@hotmail.com wrote: >Hello:Variable 'a' has the next values:[[1,1],[2,2]]and I want to take a to b as:[[1,1,'='],[2,2,'=']]How can I do this with only one line of instruction?Thanks!! To copy a list use: b=a[:] -Larry Seems I may have misunderstood the question, but others have answered appropriately. -Larry Oct 17 '06 #6

### This discussion thread is closed

Replies have been disabled for this discussion.