Created
September 28, 2016 16:30
-
-
Save codeboy101/9392df4ad4178ab3b030e0dae9ba2396 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def getEven(): | |
| num_list = [i for i in range(1,11)] | |
| for i in num_list: | |
| if i % 2 == 0: # if even number | |
| yield i | |
| x = getEven() | |
| for i in x: | |
| print(i) # output = 2,4,6,8,10 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment