Good day, please I'm writing the algorithm below in python but unittest keeps giving error no matter how i rewrite it.
This is the algorithm: Create a function get_algorithm_result to implement the algorithm below Get a list of numbers L1, L2, L3....LN as argument Assume L1 is the largest, Largest = L1 Take next number Li from the list and do the following If Largest is less than Li Largest = Li If Li is last number from the list then return Largest and come out Else repeat same process starting from step 3 Create a function prime_number that does the following Takes as parameter an integer and Returns boolean value true if the value is prime or Returns boolean value false if the value is not prime Here's my code in python : def get_algorithm_result( numlist ): largest = numlist[0] i = 1 while ( i < len(numlist) ): if ( largest < numlist[i]): largest = numlist[i] i = i + 1 numlist[i] = numlist[-1] return largest numlist = [1,2,3,4,5] largest = get_algorithm_result(numlist) print largest def prime_number(x): return len([n for n in range(1, x + 1) if x % n == 0]) <= 2 With this code it gives error message saying failure in test_maximum_number_two Then when I remove the numlist[i] = numlist[-1] The error message becomes failure in test_maximum_number_one (Using unit test) Please help, what am I writing wrong? Thanks! -- https://mail.python.org/mailman/listinfo/python-list