Write a function to find the second highest number from a list without using built-in functions.

AnswerBot
2y
Find second highest number from list without using inbuilt functions
Sort the list in descending order
Return the second element of the sorted list
Surya Pratap
3mo
numbers = [2, 4, 5, 1, 8, 10, 7] largest = numbers[0] slargest = -1 # let list contains all positive numbers for num in numbers[1:]: if num > largest: slargest, largest = largest, num elif slargest < ...read more
Anonymous
1y
l = [8,6,9,7]
for i in range(len(l)):
for j in range(i+1,len(l)):
if l[j]>l[i]:
temp = l[i]
l[i]=l[j]
l[j]= temp
print(l[1])
Add answer anonymously...
Cognizant Python Developer interview questions & answers
A Python Developer was asked Q. What is the difference between a tuple and a list?
A Python Developer was asked Q. Can you describe a problem that can be solved using recursion?
A Python Developer was asked Q. Write a function to find the second highest number from a list without using bui...read more
Popular interview questions of Python Developer
A Python Developer was asked Q1. What is the difference between a tuple and a list?
A Python Developer was asked Q2. Can you describe a problem that can be solved using recursion?
A Python Developer was asked Q3. Why is Python used in real-world applications?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

