{"id":18507,"date":"2021-08-26T10:39:04","date_gmt":"2021-08-26T05:09:04","guid":{"rendered":"https:\/\/python-programs.com\/?p=18507"},"modified":"2021-11-22T18:37:17","modified_gmt":"2021-11-22T13:07:17","slug":"python-program-to-find-the-2nd-largest-digit-in-a-given-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-2nd-largest-digit-in-a-given-number\/","title":{"rendered":"Python Program to Find the 2nd Largest Digit in a Given Number"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Find GCD of Elements in a Given Range<\/a>
\nGiven a number and the task is to find the given number’s second-largest digit.<\/p>\n

sort() method in Python:<\/strong><\/p>\n

By default, the sort() method sorts the list in ascending order.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 1732981<\/pre>\n

Output:<\/strong><\/p>\n

The given number's { 1732981 } second largest digit = 8<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 76542316<\/pre>\n

Output:<\/strong><\/p>\n

The given number's { 76542316 } second largest digit = 6<\/pre>\n

Program to Find the 2nd Largest Digit in a Given Number in Python<\/h2>\n

Below are the ways to find the given number’s second-largest digit:<\/p>\n