• use of a generator
Code
Diff
  • def fizzBuzz(num):
        for i in range(1,num):
            yield ("Fizz Buzz" if i % 3 == 0 and i % 5 == 0 else ("Fizz" if i % 3 == 0 else ("Buzz" if i % 5 == 0 else i)))
    
    list = list(fizzBuzz(17))
    
  • 1
    list = list(range(17))
    
    1+
    def fizzBuzz(num):
    
    2+
        for i in range(1,num):
    
    3+
            yield ("Fizz Buzz" if i % 3 == 0 and i % 5 == 0 else ("Fizz" if i % 3 == 0 else ("Buzz" if i % 5 == 0 else i)))
    
    22
    3
    for i in list :
    
    4
        if i % 15 == 0 :
    
    5
            list[i] = 'Fizz Buzz'
    
    6
        elif i % 3 == 0 :
    
    7
            list[i] = 'Fizz'
    
    8
        elif i % 5 ==0 :
    
    9
            list[i] = 'Buzz'
    
    10
    11
    list = list[1::]
    
    12
    for i in list:
    
    13
        print(i)
    
    5+
    list = list(fizzBuzz(17))