Skip to content

Commit

Permalink
Update FizzBuzz.py
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikitapandeyy authored Mar 17, 2023
1 parent 263bd95 commit 12b4866
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions FizzBuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# If none of the given conditions are true then just print the number!


def FizzBuzz():
num = int(input("Enter the number here: "))
def FizzBuzz(num):
for i in range(1, num + 1):
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
Expand All @@ -19,4 +18,5 @@ def FizzBuzz():
print(i)


FizzBuzz()

FizzBuzz(20) # prints FizzBuzz up to 20

0 comments on commit 12b4866

Please sign in to comment.