Skip to content

Instantly share code, notes, and snippets.

@codeboy101
Created September 28, 2016 16:30
Show Gist options
  • Select an option

  • Save codeboy101/9392df4ad4178ab3b030e0dae9ba2396 to your computer and use it in GitHub Desktop.

Select an option

Save codeboy101/9392df4ad4178ab3b030e0dae9ba2396 to your computer and use it in GitHub Desktop.
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