Sum of odd numbers

Write a function named sum_odd_numbers that takes an integer n as input and returns the sum of all odd integers from 1 to n, inclusive. Use a for loop.

If n is less than 1, the range contains no integers and the returned sum is 0.

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

Listing 1: Starter function and supplied checks for sum of odd numbers.
def sum_odd_numbers(n: int) -> int:
    # Add code here!
    pass


assert sum_odd_numbers(5) == 9
assert sum_odd_numbers(10) == 25
assert sum_odd_numbers(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. The % operator gives the remainder after division; 7 % 2 is 1.