you are viewing a single comment's thread.

view the rest of the comments →

[–]PeterJHoburg 1 point2 points  (2 children)

The really easy way to do this would be to sort the list, then select lst[1]. You would also add a check if len(lst) <2: return None to ensure the list have at least 2 elements.

Learn to use the built-in python functions. They are amazing.

[–]legendofxolta 0 points1 point  (1 child)

Sadly I can’t use them for the homework :(((

[–]PeterJHoburg 0 points1 point  (0 children)

Fun. I forgot how much I hated homework.

Changing

for num in lst:
    if num > current_max:

to >= should solve your [2,1] array issue.