Skip to content

Commit ae5afeb

Browse files
committed
Add check for RGB values
1 parent 9fcbf49 commit ae5afeb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/modulino/pixels.py

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
class ModulinoColor:
55
def __init__(self, r, g, b):
6+
if r < 0 or r > 255:
7+
raise ValueError(f"Red value {r} should be between 0 and 255")
8+
if g < 0 or g > 255:
9+
raise ValueError(f"Green value {g} should be between 0 and 255")
10+
if b < 0 or b > 255:
11+
raise ValueError(f"Blue value {b} should be between 0 and 255")
612
self.r = r
713
self.g = g
814
self.b = b

0 commit comments

Comments
 (0)