Skip to main content
added 4 characters in body
Source Link
TheCoffeeCup
  • 9.5k
  • 4
  • 38
  • 96

inIn addition to previous answers:

It is considered more Pythonic to check if not num % fizz*buzz than if num % fizz*buzz == 0

Also you don't need to use elif if there is a returnreturn statement inside if, so I'd rewrite your get_stringget_string function like this:

def get_string(num, fizz, buzz) if not num % fizz*buzz: return "FizzBuzz" if not num % fizz: return "Fizz" if not num % buzz: return "Buzz" return str(n) 

in addition to previous answers:

It is considered more Pythonic to check if not num % fizz*buzz than if num % fizz*buzz == 0

Also you don't need to use elif if there is a return statement inside if, so I'd rewrite your get_string function like this:

def get_string(num, fizz, buzz) if not num % fizz*buzz: return "FizzBuzz" if not num % fizz: return "Fizz" if not num % buzz: return "Buzz" return str(n) 

In addition to previous answers:

It is considered more Pythonic to check if not num % fizz*buzz than if num % fizz*buzz == 0

Also you don't need to use elif if there is a return statement inside if, so I'd rewrite your get_string function like this:

def get_string(num, fizz, buzz) if not num % fizz*buzz: return "FizzBuzz" if not num % fizz: return "Fizz" if not num % buzz: return "Buzz" return str(n) 
Source Link
Alissa
  • 259
  • 1
  • 5

in addition to previous answers:

It is considered more Pythonic to check if not num % fizz*buzz than if num % fizz*buzz == 0

Also you don't need to use elif if there is a return statement inside if, so I'd rewrite your get_string function like this:

def get_string(num, fizz, buzz) if not num % fizz*buzz: return "FizzBuzz" if not num % fizz: return "Fizz" if not num % buzz: return "Buzz" return str(n)