Skip to content

Instantly share code, notes, and snippets.

@MAGANER
Created March 22, 2021 20:10
Show Gist options
  • Save MAGANER/720ddbacafb1f44da551574f8071eca5 to your computer and use it in GitHub Desktop.
Save MAGANER/720ddbacafb1f44da551574f8071eca5 to your computer and use it in GitHub Desktop.
functional solution of FizzBuzz task.
def FizzBuzz(number):
is_mult_of_3 = lambda n: (n % 3) == 0
is_mult_of_5 = lambda n: (n % 5) == 0
if is_mult_of_3(number) and is_mult_of_5(number):
return "FizzBuzz"
elif is_mult_of_3(number):
return "Fizz"
elif is_mult_of_5(number):
return "Buzz"
else:
return number
numbers = list(map(FizzBuzz,range(1,101)))
print(numbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment