While Loop Implementations for the min and max functions.
def max_of_list(list):
index, max = 1, list[0]
while index < len(list):
if max >= list[index]:
index += 1
else:
max = list[index]
index += 1
return max
def min_of_list(list):
index, min = 1, list[0]
while index < len(list):
if min <= list[index]:
index += 1
else:
min = list[index]
index += 1
return min
def max_of_string(string):
stringlist = list(string)
index, max = 1, stringlist[0]
while index < len(stringlist):
if max >= stringlist[index]:
index += 1
else:
max = stringlist[index]
index += 1
return max
def min_of_string(string):
stringlist = list(string)
index, min = 1, stringlist[0]
while index < len(stringlist):
if min <= stringlist[index]:
index += 1
else:
min = stringlist[index]
index += 1
return min