PracticeStrings
Count Lowercase Moves
Context
In the arcade game Neon Vault, a player's move log is stored as a short text string. Some characters are lowercase letters, while spaces may separate move names. The scoring system awards one bonus point for every lowercase letter recorded in the log.
Problem
Write a function that counts how many characters in the move log are lowercase letters from a through z. Inspect every character exactly once. Spaces do not count, and the result is zero when the log contains no lowercase letters or has no characters.
Examples
Example 1
Input:
move_log = "ab cd ef"Output:
6Explanation: The executed call for "ab cd ef" returns 6. The final traced counter value is 6.
Example 2
Input:
move_log = "mmm n m"Output:
5Explanation: The executed call for "mmm n m" returns 5. The final traced counter value is 5.
Example 3
Input:
move_log = " "Output:
0Explanation: The executed call for three spaces returns 0. The final traced counter value is 0.
Constraints
0 <= len(move_log) <= 100000move_log contains lowercase letters and spaces.- Types:
move_logis str; result is int
Function signature
def count_lowercase_moves(move_log: str) -> int
move_logstr- The player's move log, containing lowercase letters and spaces.
- returns int
- The number of characters in move_log that are lowercase letters from a through z.
Adapted from MBPP problem task_818 (CC BY 4.0). Rewritten, extended and verified by Iksha.
Notes
- Count each qualifying character independently, including repeated letters.
- Characters other than lowercase letters must not increase the result.
Code
Saved