Please dont use max function use another method to find the

Please don\'t use max() function.

use another method to find the largest values in a list

Given a two-dimensional list the inside list have random real numbers. Return a two-dimensional list in which each inner list has the largest number of the original list For example: List = [[1, 2] [3, 4, 5], [6], [7, 8]], you would return [[2], [5], [6], [8]] Please do not use for-loops. Only while loops and if statements as much as possible. Thanks you

Solution

list1=[[1,2],[3,4,5],[6],[7,8]];
resultlist=[];
def maxnum(lis):
Maxnum = lis[0]
for num in lis:
if Maxnum < num:
Maxnum = num
return Maxnum

for i in range(0,len(list1)):
length=len(list1[i]);
for j in range(0,length+1):
resultlist.append(maxnum(list1[j]));
print(\"Max element: \",resultlist);

Please don\'t use max() function. use another method to find the largest values in a list Given a two-dimensional list the inside list have random real numbers.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site