The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

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:

–jeroen

One Response to “For your next job interview: One-Line FizzBuzz Solution in Python 3 | by David Sanchez | CodeX | Medium”

  1. […] For your next job interview: One-Line FizzBuzz Solution in Python 3 | by David Sanchez | CodeX |&nbs… […]

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.