Skip to content

Commit 12b4866

Browse files
Update FizzBuzz.py
logical issue in the FizzBuzz() function. The current implementation of the FizzBuzz() function requires the user to input the number to count up to. This limits the functionality of the function to a single use case. To make the function more flexible and reusable, we can modify the function to take the num argument as an input parameter. With this modification, we can call the FizzBuzz() function with any number you want to count up to.
1 parent 263bd95 commit 12b4866

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

FizzBuzz.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# If none of the given conditions are true then just print the number!
77

88

9-
def FizzBuzz():
10-
num = int(input("Enter the number here: "))
9+
def FizzBuzz(num):
1110
for i in range(1, num + 1):
1211
if i % 3 == 0 and i % 5 == 0:
1312
print("FizzBuzz")
@@ -19,4 +18,5 @@ def FizzBuzz():
1918
print(i)
2019

2120

22-
FizzBuzz()
21+
22+
FizzBuzz(20) # prints FizzBuzz up to 20

0 commit comments

Comments
 (0)