-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (31 loc) · 962 Bytes
/
Copy pathmain.py
File metadata and controls
42 lines (31 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""
Small Python Projects for Beginners
FizzBuzz - Let's take a look at the rules:
* If a number is divisible by 3, print the word 'Fizz' instead of the number.
* If the number is divisible by 5, print the word 'Buzz' instead of the number.
* Finally, if the number is divisible by both 3 and 5, print 'FizzBuzz' instead of the number.
* Otherwise, just print the number.
Version: 1.0
Python 3.12
Date created: February 19th, 2024
Date modified: -
"""
def check_number(number: int):
if number % 3 == 0 and number % 5 == 0:
print("FizzBuzz")
elif number % 3 == 0:
print("Fizz")
elif number % 5 == 0:
print("Buzz")
else:
print(f"{number}")
def main():
try:
number = int(input("Enter a number: "))
check_number(number)
except ValueError as e:
print(e)
print("Invalid input! Please enter a valid number.")
if __name__ == "__main__":
main()