#K52412. Count Character Categories
Count Character Categories
Count Character Categories
You are given a string which contains a mix of uppercase letters, lowercase letters, and digits. Your task is to count the number of uppercase letters, lowercase letters, and digits, and then output a dictionary with these three counts. However, if the string contains any characters that are not an uppercase letter, a lowercase letter, or a digit, you should output False
.
In other words, if we denote:
- $$U$$ as the set of uppercase letters,
- $$L$$ as the set of lowercase letters, and
- $$D$$ as the set of digits,
Then, for a given string \(s\), you need to compute:
[ |U| = \text{number of characters in } s \text{ that are uppercase}, ] [ |L| = \text{number of characters in } s \text{ that are lowercase}, ] [ |D| = \text{number of characters in } s \text{ that are digits}. ]
If any other character is found, output False
.
Note: The output should be formatted exactly as a Python dictionary if the string is valid.
inputFormat
The input consists of a single line containing the string \(s\). This string may be empty.
outputFormat
If the string is valid (only contains uppercase letters, lowercase letters, or digits), output a dictionary printed as a string with keys 'uppercase', 'lowercase', and 'digits' mapping to their respective counts. Otherwise, output the word False
.
Hello123
{'uppercase': 1, 'lowercase': 4, 'digits': 3}