You are viewing a single comment's thread from:
RE: Introducing the Coding Challenge
My solution for python:
def fizzbuzz(n):
multipleOf3 = n % 3
multipleOf5 = n % 5
if (multipleOf3 == 0 and multipleOf5 == 0):
return "FizzBuzz"
elif (multipleOf3 == 0):
return "Fizz"
elif (multipleOf5 == 0):
return "Buzz"
else:
return n
for n in range(101):
print(fizzbuzz(n))
One suggestion I would have is keep the return type of fizzbuzz consistent. So I would probably do a
return str(n)
to ensure it is always a string. And in python I would follow snake_case with my variables somultiple_of_3
would be the preferred format.Your solution looks good and I think it it correct, well done :)
lol, snake case for python. I get it! =D
I kinda wonder about these traditions of code styles and methods. It would be cool to tell a story about the history of traditions like "hello world" and such.
Thank you for the feedback. I'm come from Java. Automatically coded in it's coding style. lols
You're on the right track.
Brilliant!