Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python list tutorial for beginners

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

Python list tutorial for beginners

Vowel=['a','e','i','o','u']
if 'e' in Vowel:
print('Present')
else:
print('absent')
Comment

PREVIOUS NEXT
Code Example
Python :: python check if character in string 
Python :: py convert binary to int 
Python :: formatting strings in python 
Python :: How to perform heap sort? 
Python :: sign python 
Python :: create a range of numbers in python 
Python :: where python packages are installed 
Python :: DtypeWarning: Columns (7) have mixed types. Specify dtype option on import or set low_memory=False 
Python :: slider python 
Python :: getting url parameters with javascript 
Python :: transformer in pytorch 
Python :: how to create a subset of a dataframe in python 
Python :: bitwise operation in python 
Python :: how to print name in python 
Python :: find the range in python 
Python :: iterate python 
Python :: iteration over dictionary 
Python :: pandas difference between dates in hours 
Python :: import turtle 
Python :: read list of dictionaries from file python 
Python :: NEW CALENDAR MODULE 
Python :: k means clustering python medium 
Python :: how to use underscore in python 
Python :: pandas change diagonal 
Python :: text to png python 
Python :: python subprocess no such file or directory 
Python :: python webscraper stack overflow 
Python :: x = 10 x += 12 y = x/4 x = x + y in python 
Python :: sklearn impute 
Python :: len 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =