Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def only_odds(nums_list):
- odd_nums = []
- #iterating through the list and stating the condition that num divided by 2 must not leave a remainder equal to zero, for it to append to the odd_nums list, we have:
- for num in nums_list:
- if num % 2 != 0:
- odd_nums.append(num)
- return odd_nums
- print(only_odds([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
Advertisement
Add Comment
Please, Sign In to add comment