Toggle

alister alister.nospam.ware at ntlworld.com
Thu Oct 9 17:23:49 CEST 2014


On Thu, 09 Oct 2014 17:57:03 +1300, Gregory Ewing wrote:

> Seymore4Head wrote:
>> I want to toggle between color="Red" and color="Blue"
> 
> toggle = {"Red": "Blue", "Blue": "Red"}
> color = toggle[color]

How about a simple

colour = 'red' if colour == 'blue' else 'blue'



-- 
The light at the end of the tunnel is the headlight of an approaching 
train.



More information about the Python-list mailing list