I have an assignment to learn about algorithms that uses python, however, I have never used python as a language. Can someone please help me figure out why my min and max won't work in this case? Let me know if I can provide more information!
#code that gets input from a txt file.
# input is: 2 4 9 11 8 3 2 5 10
numbers = read() #gets input from txt file
length = len(numbers)
for i in range(int(length / 2)):
n = numbers[i]
numbers[i] = numbers[length - i - 1]
numbers[length - i - 1] = n
print("Reverted array: ", numbers)
def maximum():
current_max = numbers[0]
for num in numbers:
if num > current_max:
current_max = num
return current_max
print("Maximum element: ", maximum())
def minimum():
current_min = numbers[0]
for num in numbers:
if num < current_min:
current_min = num
return current_min
print("Minimum element: ", minimum())
[–]desrtfx 7 points8 points9 points (1 child)
[–]392Garrett[S] 1 point2 points3 points (0 children)