Objective
Create a Python program that runs a test table: a list of inputs with the expected result of each one.
Instructions
- Define
capitalize_words(text), which puts the first letter of each word in upper case and the rest in lower case:" ".join(w.capitalize() for w in text.split()). - Read an integer
nand thennlines with the formattext|expected(split them withsplit("|")). - For each case show
Test K: OKifcapitalize_words(text)equals the expected value, orTest K: FAIL (got: X)otherwise. K starts at 1. - At the end show
Passed: P of N.
3
hola mundo|Hola Mundo
PYTHON|Python
ana lópez|Ana lópez
Test 1: OK
Test 2: OK
Test 3: FAIL (got: Ana López)
Passed: 2 of 3
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise