runtime
104 / 500
question 104 String Algorithms · easy

Is this a colour code?

A theme editor accepts colours as hex codes such as #1A2b3C: a # followed by exactly six hexadecimal digits (0–9 and a–f, in either case). Spaces at the ends are allowed. Check a typed colour before saving it.

Functionvalid_colour(text)
ReturnsTrue for # plus six characters from 0123456789abcdefABCDEF (after stripping); otherwise False
Examples
callvalid_colour('#1A2b3C')returnsTrue
callvalid_colour('#12345g')returnsFalse
callvalid_colour('#ffffff')returnsTrue

Loading your progress…

Is this a colour code? — Python practice · Runtime