From 975abd11c6af0276bcd3c302518e7c1fda860220 Mon Sep 17 00:00:00 2001 From: yogeshphatangare <37510196+yogeshphatangare@users.noreply.github.com> Date: Tue, 14 Aug 2018 17:47:48 +0530 Subject: [PATCH] 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' ] --- arrays_strings/fizz_buzz/Solution_BuzzFizz.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 arrays_strings/fizz_buzz/Solution_BuzzFizz.py diff --git a/arrays_strings/fizz_buzz/Solution_BuzzFizz.py b/arrays_strings/fizz_buzz/Solution_BuzzFizz.py new file mode 100644 index 0000000..0e2ecdc --- /dev/null +++ b/arrays_strings/fizz_buzz/Solution_BuzzFizz.py @@ -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")