Do this as a list comprehension?
The Pythonista
none at this.time
Fri Jun 6 14:40:19 EDT 2008
On Thu, 05 Jun 2008 23:42:07 -0400, John Salerno wrote:
> Is it possible to write a list comprehension for this so as to produce a
> list of two-item tuples?
>
> base_scores = range(8, 19)
> score_costs = [0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3] print zip(base_scores,
> score_costs)
>
score_costs = [(base_scores[i], score_costs[i]) for i in range (len
(base_scores))]
But, I'd rather just use zip. :-)
--
code.py: A blog about life, the universe, and Python
http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
More information about the Python-list
mailing list