code issue
Tola Oj
ojomooluwatolami675 at gmail.com
Thu Apr 21 13:01:32 EDT 2022
given a number n, for each integer i in the range from 1 to n inclusive,
print one value per line as follows:
. if i is a multiple of both 3 but not 5, print fizz.
.if i is a multiple of 5 but not 3, print buzz
.if i is not a multiple of 3 or 5, print the value of i.
the above is the question. the below is my answer, but it keeps saying I'm
failing it and this is the output my code keeps giving me: it passes my
input n (Which was 13) and starts to print from 1 again. please help
-
1
-
2
-
Fizz
-
4
-
Buzz
-
Fizz
-
7
-
8
-
Fizz
-
Buzz
-
11
-
Fizz
-
13
-
1
-
2
-
Fizz
-
4
-
Buzz
-
Fizz
-
7
-
8
-
Fizz
-
Buzz
-
11
-
Fizz
-
13
-
14
-
Fizzbuzz
for i in range(1, n+1):
if i % 3 == 0 and i % 5 == 0:
print("Fizzbuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
print(i, sep='\n')
fizzbuzz(13)
More information about the Python-list
mailing list