Create Solution_BuzzFizz.py

Test Cases
* None -> Exception
* < 1 -> Exception
* 15 ->
[
    '1',
    '2',
    'Fizz',
    '4',
    'Buzz',
    'Fizz',
    '7',
    '8',
    'Fizz',
    'Buzz',
    '11',
    'Fizz',
    '13',
    '14',
    'FizzBuzz'
]
This commit is contained in:
yogeshphatangare 2018-08-14 17:47:48 +05:30 committed by GitHub
parent ba3ec6f492
commit 975abd11c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,22 @@
class Stringassign:
def change_number(self,upto_numbers):
if upto_numbers < 0:
print ("Exception")
for no in range(1,upto_numbers):
if no%3==0 and no%5==0:
print("FizzBuzz")
continue
elif(no%3)==0:
print("Fizz")
continue
elif(no%5)==0:
print("Buzz")
continue
print (no)
if __name__ == '__main__':
try:
upto_numbers=input("upto which number you want to print...?\t")
change_instance=Stringassign()
change_instance.change_number(int(upto_numbers))
except ValueError:
print("Exception")