For your next job interview: One-Line FizzBuzz Solution in Python 3 | by David Sanchez | CodeX | Medium
Posted by jpluimers on 2024/01/18
[Wayback/Archive] One-Line FizzBuzz Solution in Python 3 | by David Sanchez | CodeX | Medium
print('\n'.join(['fizzbuzz' if x%15 == 0 else 'buzz' if x%5 == 0 else 'fizz' if x%3 == 0 else str(x) for x in range(1,101)]))
(Yes, one can do similar list comprehension and conditional expression constructs in other languages to get one-liner solutions)
Via:
- [Wayback/Archive] Tim McNamara on Twitter: “Has anyone ever been asked to implement FizzBuzz in an actual job interview?”
- [Wayback/Archive] Matt 马特 on Twitter: “@timClicks Yep.
print('\n'.join(['fizzbuzz' if x==0 else "buzz" if x%5 == 0 else "fizz" if x%3 == 0 else str(x) for x in range(1, 101)]))“
–jeroen






ESXi 8 licenses seem still available, if you might need it: register while you can as it looks like Broadcom will kill registration « The Wiert Corner – irregular stream of stuff said
[…] For your next job interview: One-Line FizzBuzz Solution in Python 3 | by David Sanchez | CodeX |&nbs… […]