Objective
This function has a hidden bug. Create a program that finds it by comparing its result with the correct one in several cases.
Instructions
- Copy this function exactly as it is (even though it has the bug):
def maximum(items):withlargest = 0, a loopfor n in items:and, inside,if n > largest: largest = n; at the endreturn largest. - Read an integer
nand thennlines, each with integers separated by spaces (at least one). - For each line, compare
maximum(items)with the correct result,max(items). ShowLine K: OKif they match orLine K: FAIL (expected E, got G)otherwise. K starts at 1. - At the end show
Failures: F.
3
3 8 1
-5 -2 -9
0 0
Line 1: OK
Line 2: FAIL (expected -2, got 0)
Line 3: OK
Failures: 1
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise