Looping The Numbers
Part of the Fundamentals section of Coddy's Python journey — lesson 51 of 77.
Challenge
EasyLoop over the numbers from 1 to the number that the user entered, and each time use the function you created to calculate the FizzBuzz result and output it.
For example, for input of 7 output:
Welcome to FizzBuzz!
1
2
Fizz
4
5
Fizz
BuzzTry it yourself
print("Welcome to FizzBuzz!")
def fizzbuzz(number):
result = ""
if number % 3 == 0:
result += "Fizz"
if number % 7 == 0:
result += "Buzz"
if result == "":
result = str(number)
return result
limit = int(input())
print(fizzbuzz(limit))All lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Logical Operators Part 48Loops
For LoopWhile LoopBreakContinueRecap - FactorialThe Range FunctionNested LoopRecap - Dynamic Input3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators9Functions
Declare a FunctionArgumentsReturnRecap - Sigma FunctionRecap - Validation FunctionDefault Values12Iterating Over Sequences
Iterating Over ElementsThe Enumerate FunctionIterating Over Strings Part 1Iterating Over Strings Part 2