Exercise: Case Inverter
Leer en Español | Solve Online
Background/Motivation
Text data often comes in inconsistent cases. Being able to programmatically flip the case of characters (converting lowercase to uppercase and vice-versa) is a common string manipulation task with applications in data cleaning, text processing, and user input validation.
The Task
Implement a function case_inverter(s: str) -> str that takes a string and returns a new string with the case of each character inverted.
Specifications
- Function Name:
case_inverter - Arguments:
s(str) - Return Type:
str - Expected Output: A new string with the case of each character inverted.
Constraints
- The input string can contain letters, numbers, spaces, and symbols.
Example
Instructions
- Open
exercises/case_inverter/solution.py. - Implement the
case_inverterfunction. - Change
SUBMIT = FalsetoSUBMIT = Trueat the top of the file when you are ready to be graded. - Run
python solution.pylocally to verify your solution with the built-in self-tests.