Created
October 15, 2020 03:20
-
-
Save Bemesko/51b277c7b5c7850aaf00d18ddf6c268e to your computer and use it in GitHub Desktop.
Fizzbuzz de praticamente 1 linha usando geradores e operadores ternários!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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