Skip to content

Instantly share code, notes, and snippets.

@Bemesko
Created October 15, 2020 03:20
Show Gist options
  • Save Bemesko/51b277c7b5c7850aaf00d18ddf6c268e to your computer and use it in GitHub Desktop.
Save Bemesko/51b277c7b5c7850aaf00d18ddf6c268e to your computer and use it in GitHub Desktop.
Fizzbuzz de praticamente 1 linha usando geradores e operadores ternários!
def fizz_buzz():
num = -1
while num < 100:
num += 1
yield f"{num} {'fizz' if num % 3 == 0 else ''}{'buzz' if num % 5 == 0 else ''}"
for i in fizz_buzz():
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment