These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Here is another option to what has already been mentioned:
list=[9,6,4,10,13,2,3,5]max=float('-inf')
second_last =float('-inf')for x inlist:if x >max:
second_last =maxmax= x
elif x > second_last and x !=max:
second_last = x
print(second_last)
Hope that this helps!
Best,
Bobby
The developer cloud
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.