Using 'Or'

Steven D'Aprano steve at pearwood.info
Sat Jan 16 16:53:54 EST 2016


On Sun, 17 Jan 2016 01:06 am, Alister wrote:

> Conditional operators (or and not == etc.) need to be used in a test

Technically, that is incorrect.

> how else would you expect you print statement to be able to decided 
> which to print?


default = "I like Brussels sprouts."
message = random.choice(["", "I like boiled cabbage."])
print( message or default )



-- 
Steven




More information about the Python-list mailing list