Print an X pattern
Write a function named print_x_pattern that takes an integer n as input and prints an X pattern of asterisks (*). Use nested for loops.
Use a nonnegative size. The pattern has n rows and n columns before removing trailing spaces. Place asterisks on both diagonals and spaces elsewhere. For n = 0, print no lines. The function returns None.
Complete the supplied function in Listing 1. Keep its signature and use the checks below it.
Listing 2 shows the expected printed result.
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. print(text) displays a row followed by a newline. text.rstrip() returns a new string with trailing whitespace removed; "* ".rstrip() is "*".
range(stop) supplies integers from 0 up to, but excluding, stop; list(range(3)) is [0, 1, 2].