Find largest number in list

Given a list of integers, the Python function will find the largest number in the list. If the list is empty, the function will return None.

Problem

Given a list of integers, write a Python function to find the largest number in the list. If the list is empty, the function should return None.
Example input: [1, 2, 3, 4, 5]
Example output: 5

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
def find_largest(list):
    if len(list) == 0:
        return None
    else:
        return max(list)

print(find_largest([1, 2, 3, 4, 5]))
print(find_largest([]))

A.I. Evaluation of the Solution

This solution correctly finds the largest number in a list, and returns None if the list is empty. It uses a simple approach of just finding the maximum value in the list, which is efficient.

Evaluated at: 2022-11-19 06:16:17