I am trying some of the practice problems on leetcode
and I am running into an issue on the fizzbuzz
problem.
As far as I can tell my code
works correctly when I run
it separately in my own python
editor (pycharm) .
But when I add back in the class
and def
lines running the code
just comes back with process finished with exit
code 0.
class Solution(object):
def fizzBuzz(self, n):
ans = []
for i in range(1, 6):
if (i % 3 == 0) and (i%5 != 0):
ans.append("fizz")
if (i% 3 != 0) and (i%5 == 0):
ans.append("buzz")
if (i % 3 != 0) and (i % 5 != 0):
ans.append(str(i))
When I run
this on the websites check answer thing only get back ['1']
but if I take out the class
and def
lines it runs
as I expected it to.
Whether def
and class
do something here that changes how the program runs?