Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Use operator in python list

list1 = [10, 20, 4, 45, 99]
 
mx=max(list1[0],list1[1])
secondmax=min(list1[0],list1[1])
n =len(list1)
for i in range(2,n):
    if list1[i]>mx:
        secondmax=mx
        mx=list1[i]
    elif list1[i]>secondmax and 
        mx != list1[i]:
        secondmax=list1[i]
 
print("Second highest number is : ",
      str(secondmax))
      
 Output:-     
      
Second highest number is :  45
Comment

PREVIOUS NEXT
Code Example
Python :: pandas take entries from other column if column is nan 
Python :: Run Django application using Gunicorn 
Python :: python how to vectorize a function 
Python :: f string python 
Python :: set intersection 
Python :: percentage plot of categorical variable in python woth hue 
Python :: login required 
Python :: list add pythhon 
Python :: leetcode python 
Python :: drop pandas 
Python :: run python file from cmd 
Python :: how to get the time zones in python 
Python :: python use numphy 
Python :: django create object from dict 
Python :: python 3 
Python :: f string 
Python :: float field vs decimal field in django models 
Python :: add Elements to Python list Using append() method 
Python :: how to use str() 
Python :: how to read an xml file 
Python :: Python String count() example 
Python :: how to make a variable in python 
Python :: how to make loop python 
Python :: pack() tkinter 
Python :: map python 
Python :: add user agent selenium python canary 
Python :: asyncioevents.py", line 504, in add_reader raise NotImplementedError 
Python :: list generation for python 
Python :: python calander from Programmer of empires but updated 
Python :: coreurls.py' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import. 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =