-
Notifications
You must be signed in to change notification settings - Fork 252
Check for Number
Sar Champagne Bielert edited this page Apr 8, 2024
·
5 revisions
Unit 1 Session 2 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
- Will the list always contain only numbers?
- Yes.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Loop through a list of numbers and check each one to see if it matches the target num.
1) Loop through the input list
a) If the element matches the num, return true
2) Return the counter
def check_num(lst, num):
for item in lst:
if item == num:
return True
return False