lundi 27 avril 2020

Shorten the python if-statement syntax

Is it possible to shorten the if statements below ?

if r < 0: r = 0
elif r > 255: r = 255
if g < 0: g = 0  
elif g > 255: g = 255
if b < 0: b = 0
elif b > 255: b = 255

Aucun commentaire:

Enregistrer un commentaire