Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fizzbuzz(num) -> str:
- if type(num) != list or not num:
- return ""
- for c in num:
- if c.lower() not in "0123456789abcde":
- return ""
- if num == ["0"]:
- return ""
- last = next(reversed(num)).lower()
- if last in "369c":
- return "Fizz"
- elif last in "5a":
- return "Buzz"
- elif last == "0":
- return "Bazz"
- else:
- return ""
- #Numbers encoded in base 15
- DATA = ["0", "2", "3", "7", "5", "20", "a", "C", "4.5", "0.0", "-0.0", "", "bag5"]
- for d in DATA:
- print(f'{d}: {fizzbuzz(list(d))}')
Advertisement
Add Comment
Please, Sign In to add comment