-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFizzBuzz.py
More file actions
52 lines (38 loc) · 1.05 KB
/
FizzBuzz.py
File metadata and controls
52 lines (38 loc) · 1.05 KB
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
43
44
45
46
47
48
49
50
51
52
import sys
if len(sys.argv) == 1:
input = raw_input("What is the upper limit of your FizzBuzz? ")
count = 1
try:
int(input)
print('Fizz Buzz counting up to ' + str(input) + '.')
while count <= int(input):
if count % 3 == 0 and count % 5 == 0:
print('Fizz Buzz')
elif count % 3 == 0:
print('Fizz')
elif count % 5 == 0:
print('Buzz')
else:
print(count)
count += 1
except ValueError:
print('Please provide an integer value.')
elif len(sys.argv) == 2:
try:
input = int(sys.argv[1])
count = 1
print('Fizz Buzz counting up to ' + str(input) + '.')
while count <= int(input):
if count % 3 == 0 and count % 5 == 0:
print('Fizz Buzz')
elif count % 3 == 0:
print('Fizz')
elif count % 5 == 0:
print('Buzz')
else:
print(count)
count += 1
except ValueError:
print 'Please supply an integer value as an argument.'
elif len(sys.argv) > 2:
print('Please only input one argument!')