I'm creating a Fizzbuzz code but there is a problem with the code where the result is like this:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Here is my code:
word = [3,5]
ans = ["Fizz","Buzz"]
i = 1
j = 0
result = ""
while i <= 20:
while j <= len(word)-1:
if i % int(word[j]) == 0 : result += ans[j]
if result == "" : result = str(i)
j+=1
print(result)
i+=1
The code check on list of the numbers and output the the result or else it will output the number itself.