- 1

How can I solve FizzBuzz problem?

I don't understand how will I solve this?

1st Apr 2021, 11:42 AM
Chinmoy Roy
Chinmoy Roy - avatar
8 Réponses
+ 3
the last section says you need to skip even numbers. add another if statement. if x % 2 == 0: # how to test for an even number ... ...
1st Apr 2021, 12:03 PM
Slick
Slick - avatar
+ 2
as Slick suggested, I will only add if x % 2 == 0: continue # to pass even nums # try to put this condition in the correct place
1st Apr 2021, 12:06 PM
iTech
iTech - avatar
+ 1
Hi! Please, show us your attempt. You have a code?
1st Apr 2021, 11:44 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Post your code so we can help. If you haven't written any yet, i suggest you go back over the previous lesson
1st Apr 2021, 11:44 AM
Slick
Slick - avatar
0
n = int(input()) for x in range(1, n): if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") else: print(x) # I can't solve it yet. #The question is: The given code solves the FizzBuzz problem and uses the words "Solo" and "Learn" instead of "Fizz" and "Buzz". It takes an input n and outputs the numbers from 1 to n. For each multiple of 3, print "Solo" instead of the number. For each multiple of 5, prints "Learn" instead of the number. For numbers which are multiples of both 3 and 5, output "SoloLearn". You need to change the code to skip the even numbers, so that the logic only applies to odd numbers in the range. # so help me there.
1st Apr 2021, 11:56 AM
Chinmoy Roy
Chinmoy Roy - avatar
0
Agregar en el primer elif lo siguiente: elfi x % 2 == 0: print("") no hay necesidad de imprimir el número, solo que sea la primera iteración y que omita el número par.
2nd Mar 2022, 4:18 PM
Byron Carrera
- 1
You need to follow the suggestions already given to you...twice. In the correct place add: elif x % 2 == 0: continue
2nd Apr 2021, 11:16 AM
JediMastrBob
JediMastrBob - avatar