Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

FizzBuzz in Python Using itertools

import itertools as its
def fizz_buzz(n):
    fizzes = its.cycle([""] * 2 + ["Fizz"])
    buzzes = its.cycle([""] * 4 + ["Buzz"])
    fizzes_buzzes = (fizz + buzz for fizz, buzz in zip(fizzes, buzzes))
    result = (word or n for word, n in zip(fizzes_buzzes, its.count(1)))
    for i in its.islice(result, 100):
        print(i)
Comment

PREVIOUS NEXT
Code Example
Python :: create view django not saving image 
Python :: give the factorials of 6 in python 
Python :: allowed_hosts error ecs django 
Python :: saving a dta file 
Python :: how-to-add-new-column-to-an-dataframe-to-the-front-not-end 
Python :: import image files from folders 
Python :: Python Anagram Using sorted() function 
Python :: Example pandas.read_hdf5() 
Python :: link prettify in beautifulsoup 
Python :: accessing multiple elements from the list 
Python :: int to floats 
Python :: ascii julius caesar python encryption 
Python :: Add 1 to loops 
Python :: python count files fast 
Python :: frozenset numbers in python 
Python :: convert float array to integer 
Python :: move python file 
Python :: Python NumPy atleast_3d Function Example 
Python :: python antigravity 
Python :: data framing with Pandas 
Python :: Python NumPy vstack Function Example with 2d array 
Python :: Python NumPy insert Function Example Using insertion at different points 
Python :: pandas dt.weekday to string 
Python :: NumPy rot90 Example Rotating Twice 
Python :: saving specific column with pd 
Python :: Break up long line of code to span over several lines 
Python :: adjoint of 3x3 matrix in numpy 
Python :: print python age input 
Python :: pygame getting your charecter to jump 
Python :: operasi tipe data integer 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =