import argparse parser = argparse.ArgumentParser("fizz-buzz-string.py") parser.add_argument('number', metavar='N', type=int) args = parser.parse_args() print(args.number) def getFizzBuzzString(num): text = '' for i in range(num): cur = i + 1 print(cur) if ((cur % 15) == 0): text = text + 'FizzBuzz' elif ((cur % 5) == 0): print('a') text = text + 'Buzz' print(text) elif ((cur % 3) == 0): text = text + 'Fizz' else: text = text + str(i) print(text) return text def count(text): count = 0 for w in text: if w == 'z': count = count + 1 return count number = args.number text = getFizzBuzzString(number) print(count(text))