[Tutor] String slicing from tuple list
Kent Johnson
kent37 at tds.net
Fri Jul 22 02:55:03 CEST 2005
cgw501 at york.ac.uk wrote:
> Hi Kent,
>
> Thanks for you solution, unfortunately, as Luis correctly inferred, I'm
> doing computational biology, so my real data is HUGE and I got this error:
>
> Traceback (most recent call last):
> File "stolen.py", line 62, in ?
> first, second = zip(nonGenic)
> ValueError: too many values to unpack
That is a coding error, it should be zip(*nonGenic) <- note the asterisk.
>>> data = [(1423, 2637),(6457, 8345),(9086, 10100),(12304, 15666)]
>>> first, second = zip(data)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: too many values to unpack
>>> first, second = zip(*data)
>>>
Kent
More information about the Tutor
mailing list