diff --git a/functionBonus.py b/functionBonus.py new file mode 100644 index 0000000..3838e26 --- /dev/null +++ b/functionBonus.py @@ -0,0 +1,10 @@ +def get_pattern(n: int) -> str: + result = [] + for i in range(n, 0, -1): + line = ' '.join(str(x) for x in range(i, 0, -1)) + result.append(line) + return '\n'.join(result) + +# Example usage +pattern_result = get_pattern(5) +print(pattern_result) \ No newline at end of file diff --git a/labFunction.py b/labFunction.py new file mode 100644 index 0000000..17ecd84 --- /dev/null +++ b/labFunction.py @@ -0,0 +1,11 @@ +## Create a function that takes 1 parameter of type int , +# then it prints out the result formatted like the following patter (if we give it 5 for example): + +def print_pattern(n: int): + for i in range(n, 0, -1): + # Create a list of numbers from i down to 1 + line = ' '.join(str(x) for x in range(i, 0, -1)) + print(line) + +# Example usage +print_pattern(5) \ No newline at end of file