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.
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create a function that counts how many even numbers are in a list of integers.
1) Create an empty list to store the results
2) For each element in the list
a) Check if the number is odd
b) If so, add it to the results list
3) Return the results list
⚠️ Common Mistakes
def get_odds(lst):
odds = []
for num in lst:
if num % 2 == 1:
odds.append(lst)
return odds