+ 2

# Who can explain this question ??

FizzBuzz is a well known programming assignment, asked during interviews. 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. What is missing that did not write: https://code.sololearn.com/c55ri8q14OB8/?ref=app

2 Antworten

+ 5

You only need to iterate ODD numbers so in your line 3 of your code, it should be:
for x in range(1, n, 2):
# Parameters:
range(start, end, steps)
Since your start number is 1, the range/iteration steps should be 2 for it to iterate only odd numbers.
Hope this helps.

+ 4

Wow, that was cool how I couldn't focus on this point 😅😅
But you're really good at it. Thanks for the help