Tutte le sfide
Facile 0 risolte 0% di accettazione

Count Uppercase Letters

Count the capital letters in a text.

Count how many characters in text are uppercase English letters A–Z.

Implement count_uppercase(text).

Input

text: The text to inspect.

Output

Return the number of uppercase letters.

Vincoli

0 ≤ length of text ≤ 10,000 (ASCII characters)

Esempi

Esempio 1
Input:
text = "Hello World"

Output atteso:
expected = 2
Input:
std::string text = "Hello World";

Output atteso:
long long expected = 2;
Input:
string text = "Hello World";

Output atteso:
long expected = 2;

Spiegazione

H and W are uppercase: 2.

Esempio 2
Input:
text = "no caps here!"

Output atteso:
expected = 0
Input:
std::string text = "no caps here!";

Output atteso:
long long expected = 0;
Input:
string text = "no caps here!";

Output atteso:
long expected = 0;

Spiegazione

There are no uppercase letters: 0.

Riferimenti

Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.

Impara dagli altri

Soluzioni della community

Nessuna soluzione pubblicata. Risolvi questa sfida per condividere la prima.