Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FizzBuzz:
- def __init__(self, start, stop):
- self.start = start
- self.stop = stop + 1
- def value_for(self, value):
- output = ""
- if value % 3 == 0:
- output += "Fizz"
- if value % 5 == 0:
- output += "Buzz"
- if len(output) == 0:
- output = str(value)
- return output
- def fizz(self):
- results = []
- for candidate in range(self.start, self.stop):
- results.append(self.value_for(candidate))
- return results
- fizzer = FizzBuzz(1, 100)
- for result in fizzer.fizz():
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement