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
525 Uncaught (inpromise) Error on Electron: An object could not be cloned
545 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
545 Understanding How to Configure Google API Key
682 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
546 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.