question 203 Dates Numbers & Regex · easy
Find the invalid SKU codes
A supplier's price list must use Runtime Market SKUs: three capital letters, a dash and five digits, like HOM-52782. Before importing it, list the codes that don't have exactly that shape.
Function
bad_skus(codes)Validexactly
[A-Z]{3}-\d{5} for the whole code: no spaces, no extra characters before or afterReturnsa new list of the invalid codes, in their original order;
[] when all are validExamples
callbad_skus(['HOM-52782', 'hom-52782', 'BOO-5841', 'GRO-63674 '])returns['hom-52782', 'BOO-5841', 'GRO-63674 ']
callbad_skus(['HOM-52782', 'ELE-24781'])returns[]
callbad_skus([])returns[]