Handling 3 operands in an expression without raising an exception

Maarten maarten.sneep at knmi.nl
Thu Sep 26 05:52:49 EDT 2013


On Thursday, September 26, 2013 11:31:29 AM UTC+2, Ferrous Cranus wrote:

> I have tried code and also provided alternative code to solve my problem 
> which also doesn't solve it.
> 
> So, you cannot accuse me that i'm not trying, that would be the case to 
> just ask for a line without trying anything for myself, which i did twice.

I'll accuse you of being a dimwit. The questions you ask do not show you trying. The code that _is_ posted is not straightforward or geared towards readability.

> Also when a solution is being provided to me i do not only want to use 
> it but want to understand too, so if something similar comes up i will 
> be in a position to solve it that time.

If you really want to do that, then why do you insist on one-liners? Write out the logic with a sequence of if statements. That is easy to understand, gives clearer error messages. The solution by Nobody is fairly foolproof, and the logic is clear. What's not to like? 

Maarten



More information about the Python-list mailing list