Created
October 27, 2020 11:50
-
-
Save Kush1101/83860d71a8b647ba8a42b3fc79bae302 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import takewhile | |
iterable = [1, 3, 5, 7, 2, 4, 6, 9, 11] | |
predicate = lambda x: x%2==1 | |
for i in takewhile(predicate, iterable): | |
print(i, end = ' ') | |
# OUTPUT | |
""" | |
1 3 5 7 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment