Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Work'
- from itertools import cycle, izip, count, islice
- fizzes = cycle( [""] * 2 + ["Fizz"] )
- '''
- itertools.cycle( iterable )
- Make an iterator returning elements from the iterable and saving a copy of each.
- When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely.
- Equivalent to:
- def cycle(iterable):
- # cycle('ABCD') --> A B C D A B C D ...
- saved = []
- for element in iterable:
- yield element
- saved.append(element)
- while saved:
- for element in saved:
- yield element
- '''
- count = 1
- while count < 100:
- if count % 3 == 0 and count % 5 == 0:
- #if count % 5 == 0:
- # print("FizzBuzz")
- #else:
- #print("Fizz")
- print("FizzBuzz")
- elif count % 3 == 0:
- print("Fizz")
- elif count % 5 == 0:
- print("Buzz")
- else:
- print(count)
- count += 1
- for i in range(1, 101): print( "Fizz"*( i % 3 == 0 ) + "Buzz"*( i % 5 == 0 ) or i )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement