<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV id=yiv518461647>
<TABLE id=yiv518461647bodyDrftID class=yiv518461647 border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD style="FONT-FAMILY: arial; FONT-SIZE: 10pt" id=yiv518461647drftMsgContent>
<DIV id=yiv518461647>
<TABLE id=yiv518461647bodyDrftID class=yiv518461647 border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD style="FONT-FAMILY: arial; FONT-SIZE: 10pt" id=yiv518461647drftMsgContent>
<DIV>Hi Expert,</DIV>
<DIV>Thanks for your responses and help. thought I should provide more information for clarity.</DIV>
<DIV> </DIV>
<DIV>Please find the error message below for more information </DIV>
<DIV> </DIV>
<DIV> for (key, value) in wordFreq2:<BR>ValueError: need more than 1 value to unpack</DIV>
<DIV> </DIV>
<DIV>this is a sample of my data</DIV>
<DIV> </DIV>
<DIV>['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2,
'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', 1, '600am', 1, '100pm', 1, '', 3, 'other']</DIV>
<DIV> </DIV>
<DIV>What I would like to do is to pad the last value 'other' with a default so I can iterate sucessfully</DIV>
<DIV> </DIV>
<DIV>my desired ouput is the format below in a text file.</DIV>
<DIV>with 3</DIV>
<DIV>which 3</DIV>
<DIV>were 2</DIV>
<DIV>..</DIV>
<DIV>.</DIV>
<DIV>. </DIV>
<DIV>other</DIV>
<DIV> <BR></DIV>
<DIV>Thanks again.</DIV>
<DIV>Sammy</DIV>
<DIV><BR>--- On <B>Tue, 2/7/12, Dave Angel <I><d@davea.name></I></B> wrote:<BR></DIV>
<BLOCKQUOTE style="BORDER-LEFT: rgb(16,16,255) 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px"><BR>From: Dave Angel <d@davea.name><BR>Subject: Re: iterating over list with one mising value<BR>To: "Sammy Danso" <samdansobe@yahoo.com><BR>Cc: python-list@python.org<BR>Date: Tuesday, February 7, 2012, 2:46 PM<BR><BR>
<DIV class=yiv518461647plainMail>On 02/07/2012 07:27 AM, Sammy Danso wrote:<BR>> Hello experts,<BR>> I am having trouble accessing the content of my list.<BR>> my list content has 2-pair value with the exception of one which has single value. here is an example ['a', 1, 'b', 1, 'c', 3, 'd']<BR>> I am unable to iterate through list to access invidual value pairs<BR>> I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem?<BR>> Your help would be much appreciated.<BR>> Thanks<BR>> Sammy<BR>The real answer is to figure out how it gets into that state. Is the input file invalid? Or you have a device that sometimes skips one?<BR><BR>But if you're stuck with the data in that list:<BR><BR>If the list is of odd size, truncate it. Then your loop should not run into an
uneven pair.<BR><BR>Of course if you actually posted the code, or even the real and complete error message, we might be able to make other suggestions.<BR><BR><BR><BR>-- <BR>DaveA<BR><BR></DIV></BLOCKQUOTE></TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE></DIV></td></tr></table>