About 3,920,000 results
Open links in new tab
  1. Python - Find second smallest number - Stack Overflow

    Nov 6, 2014 · Outside of the function you found, it's almost just as efficient to use the heapq.nsmallest() function to return the two smallest values from an iterable, and from those …

  2. Largest, Smallest, Second Largest, Second Smallest in a List-Python

    Mar 3, 2025 · This approach utilizes Python’s built-in max () and min () functions to find the largest and smallest elements. By removing them from the list, we can efficiently determine the …

  3. integer - finding minimum variable in Python - Stack Overflow

    Jul 10, 2015 · I have some integer variables and I want to find smallest one. When I use: m1 = min (v1, v2, ...) I get the value of the smallest one, not its name. I want to know which one is …

  4. Python - Get second smallest number without using array

    May 20, 2021 · import sys numbers = 5 second = sys.maxsize smallest = sys.maxsize for x in range (0, numbers): use = int (input ('Enter #' + str (x + 1) + ': ')) if use < smallest: second = …

  5. Find second Smallest or Largest number in a List in Python

    Apr 10, 2024 · To find the second smallest number in a list: Use the set() class to convert the list to a set. Use the sorted() function to get a sorted list. Access the list item at index 1 to get the …

  6. Write a Python function to find the second smallest element in a …

    ## Finding the Second Smallest Element in a List Using Python When working with lists in Python, one common task is to find the second smallest element. This can be achieved efficiently with …

  7. Python Program to Find the Second Smallest Number in a List

    This article is created to cover some programs in Python that find and print the second-smallest element or number in a list entered by the user. Here is a list of programs: Find the second …

  8. Python: Find the second smallest number in a list - w3resource

    Apr 19, 2025 · uniq_items. sort () # Return the second smallest item from the sorted 'uniq_items' list, which is at index 1 return uniq_items [1] # Call the 'second_smallest' function with different …

  9. 5 Best Ways to Find the Largest, Smallest, Second Largest

    Mar 11, 2024 · To find the smallest or largest values without sorting, you can use a min or max heap data structure which allows retrieving the smallest or largest value in constant time. The …

  10. Find Second Lowest Number in Python List | Two Smallest Values

    In this first example, we will use the built-in sorted () function to obtain the second lowest number in the list: In this example, a new list called sorted_list is created by sorting the elements of …

  11. Some results have been removed
Refresh