- 1

Create a classic FizzBuzz program in python that loops from 0-100 and outputs FIZZ when the number is even, Buzz when the numbe

HERE'S MY SOLUTION.. PLEASE HELP . . https://code.sololearn.com/cy3EiBm1av2x/?ref=app

21st Apr 2022, 10:43 PM
Fahad Sheriff
5 Answers
+ 1
https://code.sololearn.com/cTm0CZyHq3h2/?ref=app
22nd Apr 2022, 11:02 AM
Oma Falk
Oma Falk - avatar
0
Mirielle i have attached the link.. Please help
21st Apr 2022, 11:44 PM
Fahad Sheriff
0
Now pls edit the question telling us what help you need
21st Apr 2022, 11:52 PM
Emerson Prado
Emerson Prado - avatar
0
It skips past required numbers 0 and 1. The for loop in is_prime always exits in its first iteration. That is because both branches of the if/else statement inside the loop end with a return statement. The break statement after the return is unreachable. There is unnecessary logic and unreachable code in the Fizzbuzz function. Below I have reduced the code and put it into workable condition: #MY FIZBUZZ #Define a prime number def is_prime(x): if x <= 1: return False for primes in range(2,x): if x % primes == 0 : return False return True def Fizzbuzz(Number): for y in range (0, Number+1): if is_prime(y): print (f"{y} FizzBuzz") elif y % 2 == 0: print ("Fizz") else: print ("Buzz") Fizzbuzz(100)
22nd Apr 2022, 12:57 AM
Brian
Brian - avatar