PracticeStrings

Count Lowercase Moves

BeginnerStringstraversalaccumulationcomparison Time not estimated Not started

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: 6
Explanation: 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: 5
Explanation: The executed call for "mmm n m" returns 5. The final traced counter value is 5.
Example 3
Input: move_log = " "
Output: 0
Explanation: The executed call for three spaces returns 0. The final traced counter value is 0.

Constraints

  • 0 <= len(move_log) <= 100000
  • move_log contains lowercase letters and spaces.
  • Types: move_log is str; result is int

Function signature

def count_lowercase_moves(move_log: str) -> int
move_log str
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.
Approved · cb046-abs_218_v214 execution-verified tests
Code
Saved
Checking environment…Python SandboxLn 1, Col 1