def maxFunc(t):
max = 0
for i in range(10):
if t >= max:
max = t
return max
A = [1, 2, 3, 4, 5, 6, 73, 8, 10, 54]
maxNum = list(map(maxFunc, A))
print(maxNum)
It's a code that prints the largest value among the internal values of the list, but I'm asking because the error code keeps coming up no matter how I fix it.
If you can, I'd appreciate it if you could include an explanation
map()
is not required, and range()
is also useless.
A = [1, 2, 3, 4, 5, 6, 73, 8, 10, 54, 9, 9, 9, 9, 9]
def maxFunc(t):
max = 0
For it: # <--- (2) Every time this is executed, i changes in order of 1, 2, 3, ..., 9
Ifi >=max: # <--- (3) It compares well with max
max = i
return max
B = maxFunc(A) # <--- (1) Place A in the t position of the function maxFunc and solve the problem
print(B) # ---> (4) Works well
© 2025 OneMinuteCode. All rights reserved.