Created
July 3, 2018 22:34
-
-
Save Fhernd/808c4fd0a10ea43ee340601059121894 to your computer and use it in GitHub Desktop.
Escribir sobre un archivo no existente. OrtizOL.
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 generador_fibonacci(): | |
fib1 = 0 | |
fib2 = 1 | |
while True: | |
yield fib2 | |
fib1, fib2 = fib2, fib1 + fib2 | |
with open('fibonaccis-2.txt', 'xt') as f: | |
contador = 1 | |
for fib in generador_fibonacci(): | |
f.write(str(fib)) | |
if contador == 10: | |
break | |
contador += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment