Electrical resistors (3.5 points)¶
A company that makes electrical resistors uses codes to
represent its products. These product codes include letters, digits
and the following four special characters: '-', '_', '*' and
'/'.
The head of the production department wants to know how many
occurrences are in a product code following this pattern: a special
character followed by a digit. For example in the product code
'22-6489/4_97*ABC' there are three of such occurrences:'-6',
'/4' and '_9'.
Write function resistor() that takes a product code
(str) and returns the number of described occurrences
(int) that contains.
Save this function in file resistor.py.
Examples:
>>> resistor('22-6489/4_97*ABC')
3
>>> resistor('21-AS*DF/3')
1
>>> resistor('21-AS*DF/X')
0
Note
More tests are provided in file test-resistor.txt.