Print a triangle pattern
Write a function named print_triangle_pattern that takes these inputs:
- integer
n: the height of the triangle; - string
side: either"left"or"right".
The function must print a triangle pattern of n lines made of asterisks (*), aligned to the requested side. Use for loops.
Use a nonnegative height. Print 1 asterisk on the first line, 2 on the next, and continue through n. Right alignment uses leading spaces so every row ends in the same column. 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.
Run the additional example in Listing 3.
Listing 4 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 the supplied string followed by a newline; print("**") prints a row of 2 asterisks.
range(stop) supplies integers from 0 up to, but excluding, stop; list(range(3)) is [0, 1, 2].