Largest Element in List

Find the largest element in a list of numbers.

BeginnerTopic: List Programs
Back

Python Largest Element in List Program

This program helps you to learn the fundamental structure and syntax of Python programming.

Try This Code
# Program to find largest element in a list

numbers = list(map(float, input("Enter numbers separated by space: ").split()))

if not numbers:
    print("List is empty.")
else:
    print("Largest element:", max(numbers))
Output
Enter numbers separated by space: 3 7 2 9
Largest element: 9.0

Understanding Largest Element in List

We use the built-in max() to obtain the largest value, with an empty-list check.

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.

Table of Contents