---
title: "Find the largest number in a list"  
description: "Find the largest number in a list"  
author: "ICSM Computer"  
published: 2025-09-04  
updated: 2025-09-04  
canonical: https://www.mindstick.com/interview/34367/find-the-largest-number-in-a-list  
category: "python"  
tags: ["python-3.4", "Python 3"]  
reading_time: 2 minutes  

---

# Find the largest number in a list

#### Method 1: Using Loop (Manual method)

```python
def find_largest(nums):
    largest = nums[0]
    for n in nums:
        if n > largest:
            largest = n
    return largest

print(find_largest([10, 45, 2, 67, 89, 23]))
```

**Output:** `89`

## Explanation:

1. Start with the first element as the largest.
2. Compare with each element and update if bigger.
3. The max is `15`.

#### Method 2: Using `max()` (Simplest way)

```python
numbers = [10, 45, 2, 67, 89, 23]

largest = max(numbers)
print("Largest number is:", largest)
```

## Output:

```plaintext
Largest number is: 89
```

#### Method 3: Using Sorting

```python
numbers = [10, 45, 2, 67, 89, 23]

largest = sorted(numbers)[-1]
print("Largest number is:", largest)
```

## Answers

### Answer by ICSM Computer

#### Method 1: Using Loop (Manual method)

```python
def find_largest(nums):
    largest = nums[0]
    for n in nums:
        if n > largest:
            largest = n
    return largest

print(find_largest([10, 45, 2, 67, 89, 23]))
```

**Output:** `89`

## Explanation:

1. Start with the first element as the largest.
2. Compare with each element and update if bigger.
3. The max is `15`.

#### Method 2: Using `max()` (Simplest way)

```python
numbers = [10, 45, 2, 67, 89, 23]

largest = max(numbers)
print("Largest number is:", largest)
```

## Output:

```plaintext
Largest number is: 89
```

#### Method 3: Using Sorting

```python
numbers = [10, 45, 2, 67, 89, 23]

largest = sorted(numbers)[-1]
print("Largest number is:", largest)
```


---

Original Source: https://www.mindstick.com/interview/34367/find-the-largest-number-in-a-list

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
