[Tutor] Help with excetion handing and making my code more efficient needed please

Luke Paireepinart rabidpoobear at gmail.com
Sat May 19 21:04:15 CEST 2007


Matt Smith wrote:
>> the possible combinations of values from the two tuples?
>> see my other reply, Matt.
>> -Luke
>>     
>
> Hi Luke,
>
> Sorry if I'm missing something but which other reply?
>   
All the info in my other reply Alan reiterated, I believe.
You can just subtract 1 from the total at the end.
Your ISP believes I'm spamming you and won't let my e-mails get through,
but the Tutor has you listed as a recipient of the mail, so it didn't 
send you a copy of that particular e-mail.
SO, for you, there was no other reply, I guess.

Basically what i said was:
You're expecting an IndexError, and if one occurs, you're assuming that 
that neighbor doesn't count,
So just put the code Rikard sent you in the try block and in the except 
block, put 'pass' (i.e. "Do Nothing").

And:
 You can add an if statement to remove this case [of counting the square 
that you're currently checking],
 or,  easier (and probably more efficient) just subtract 1 from your end 
result.
-Luke


More information about the Tutor mailing list