Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. # a generator that yields items instead of returning a list
  2. def firstn(n):
  3.     num = 0
  4.     while num < n:
  5.         yield num
  6.         num += 1
  7.  
  8. sum_of_first_n = sum(firstn(1000000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement