Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This program declares a function that accepts a list of numbers and return a list with only odd numbers
- #function
- def only_odds(list_of_numbers):
- odd_numbers = [ ]
- for number in list_of_numbers:
- if number%2==1:
- odd_numbers.append(number)
- print(odd_numbers)
- only_odds([1, 3, 5, 6, 7, 8]) #Example (The argument must be a list containing numbers only)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement