diff --git a/fullstack-cert/python-projects/letter-frequency-counter-lab/main.py b/fullstack-cert/python-projects/letter-frequency-counter-lab/main.py new file mode 100644 index 00000000..7b288a4c --- /dev/null +++ b/fullstack-cert/python-projects/letter-frequency-counter-lab/main.py @@ -0,0 +1,12 @@ +def number_pattern(n): + result = "1" + if isinstance(n, int): + if n > 0: + for i in range(2, n + 1): + result += f" {i}" + return result + return "Argument must be an integer greater than 0." + return "Argument must be an integer value." + + +print(number_pattern(13)) diff --git a/fullstack-cert/python-projects/letter-frequency-counter-lab/user-stories.md b/fullstack-cert/python-projects/letter-frequency-counter-lab/user-stories.md new file mode 100644 index 00000000..a1009423 --- /dev/null +++ b/fullstack-cert/python-projects/letter-frequency-counter-lab/user-stories.md @@ -0,0 +1,5 @@ +1. You should define a function named `number_pattern` that takes a single parameter `n` (representing a positive integer). +1. `number_pattern` should use a `for` loop. +1. `number_pattern(n)` should return a string with all the integers starting from 1 up to `n` (included) separated by a space. For example, `number_pattern(4)` should return the string `1 2 3 4`. +1. If the argument passed to the function is not an integer value, the function should return `Argument must be an integer value.`. +1. If the argument passed to the function is less than 1, the function should return `Argument must be an integer greater than 0.`. \ No newline at end of file