In this program, we will take a user input as a list. Find the second smallest number from the list with the help of the below-given steps.
Second smallest number in a list:
Steps to solve the program
- Take a list as input.
- Sort the list using sort().
- Print the second smallest number from the list using indexing.
#Input list
list1 = [22,11,78,45,90,44]
#Sorting the list
list1.sort()
#Printing output
print("2nd smallest number: ", list1[1])
Output :
2nd smallest number: 22
Related Articles
Python program to merge all elements of the list in a single entity using a special character.
Python program to get the difference between two lists.
Python program to reverse each element of the list.
Python program to combine two list elements as a sublist in a list.
Python program to get keys and values from the list of dictionaries.
Python program to get all the unique numbers in the list.