Advertisement
Mofeoluwa

OnlyOdds

Feb 29th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. def only_odds(list1):
  2.     x = [] #create and empty list
  3.     for i in list1: #loop through the elements in list1
  4.         if i%2 == 1: #if any of the elements in list1 is odd
  5.             x.append(i) #add the object to a new list
  6.     print(x) #print x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement