Smallest Element in List
Find the smallest element in a list of numbers.
BeginnerTopic: List Programs
Python Smallest Element in List Program
This program helps you to learn the fundamental structure and syntax of Python programming.
# Program to find smallest element in a list
numbers = list(map(float, input("Enter numbers separated by space: ").split()))
if not numbers:
print("List is empty.")
else:
print("Smallest element:", min(numbers))Output
Enter numbers separated by space: 3 7 2 9 Smallest element: 2.0
Understanding Smallest Element in List
We use the built-in min() to obtain the smallest value, again checking for an empty list.
Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.