You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Understand what the interviewer is asking for by using test cases and questions about the problem.
What is the input?
An integer stop.
What should the function do?
Print every number from 1 up to and including stop, each on its own line. It does not return anything.
What if stop is less than 1?
Nothing is printed, because there are no numbers from 1 up to stop.
HAPPY CASE
Input: stop = 3
Output:
1
2
3
Explanation: The numbers 1, 2 and 3 are printed in order, including stop itself.
EDGE CASE
Input: stop = 0
Output: (nothing is printed)
Explanation: range(1, 1) is empty, so the loop body never runs.
P-lan
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create a function to count from 1 to stop.
1) Create a new function with a parameter for the stop value
2) For each number between 1 and stop + 1, print that value
⚠️ Common Mistakes
Why would we go to "stop + 1" and not just "stop"?