Factorial of a number

Write a function named factorial that takes a non-negative integer n as input and returns the factorial of n. Use a for loop.

The factorial is the product of integers from 1 through n. By definition, 0! is 1.

Complete the supplied function in Listing 1. Keep its signature and use the checks below it.

Listing 1: Starter function and supplied checks for factorial of a number.
def factorial(n: int) -> int:
    # Add code here!
    pass


assert factorial(5) == 120
assert factorial(0) == 1
assert factorial(1) == 1

range(start, stop) supplies integers beginning at start and ending before stop. For example, list(range(1, 4)) is [1, 2, 3]. An empty range supplies no values.

assert condition stops the check with an AssertionError when the condition is false.