Hướng dẫn thử thách
1 / 1
Build a Range of Numbers Generator
In this lab, you will build a `range_of_numbers` function that uses recursion to generate a list of numbers within a specified range.
For example:
- `range_of_numbers(3, 9)` should return `[3, 4, 5, 6, 7, 8, 9]`.
- `range_of_numbers(5, 5)` should return `[5]`.
Fulfill the user stories below and get all the tests to pass to complete the lab.
**User Stories:**
1. You should create a function named `range_of_numbers` with two parameters named `start_num` and `end_num`.
1. The function should return a list of consecutive integers that begins with `start_num` and ends with `end_num`, including both values.
1. The value of `start_num` will always be less than or equal to `end_num`.
1. Your function should use recursion by calling itself.
1. Your function should not use `for` or `while` loops, comprehensions, or the `range()` function.
1. When `start_num` equals `end_num`, the function should return a list containing `start_num`. This is the base case.
1. For the recursive case, the function should call itself with an argument that moves toward the base case, then add the current number to the returned list.
1. The function should not use global variables to store the returned list.
Vượt qua bài kiểm tra hiện tại để mở khóa bài tiếp theo.
main.py
UTF-8 • Tab Size: 2Kiểm tra bài:⌘↵