Day 8The Missing Number

    Easylistsmath

    A list contains every whole number from 0 to n except one, in any order. Write missing_number(nums) that returns the missing number.

    For [3, 0, 1], n is 3 and the missing number is 2.

    Examples

    Example 1
    >>> missing_number([3, 0, 1])
    2
    Example 2
    >>> missing_number([0, 1])
    2

    Good to know

    • The list has n numbers, so n is len(nums). The missing one can be 0 or n itself.

    Run examples checks the 2 examples above. Submit runs all 6 tests, including hidden edge cases, and marks the challenge solved.

    solution.py
    Loading Python…

    Test results show up here

    Write missing_number in the editor, then run the examples. Use print() freely: its output is shown for each test.