describe
Find the number of uppercase characters (i.e. 'A'-'Z') in the given string.
Data range: String length: 1≤∣�∣≤250 1≤∣s∣≤250
The string may contain spaces or other characters
Advanced: Time complexity: �(�) O(n), Space complexity: �(�) O(n)
Enter description:
For each set of samples, enter a line representing the string to be counted.
Output description:
Output an integer representing the number of uppercase letters in the string
Example 1
enter:
A 1 0 1 1150175017(&^%&$vabovbaoadd 123#$%#%#O
Output:
2
Java:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
System.out.println(in.nextLine().replaceAll("[^A-Z]","").length());
}
}
}
python:
while True:
try:
n = input()
c = ''
for i in n: