Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 29, 2018 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/f806b55a6ef2ddc91c7d57a1082ccc3a to your computer and use it in GitHub Desktop.
Save Fhernd/f806b55a6ef2ddc91c7d57a1082ccc3a to your computer and use it in GitHub Desktop.
Imprimir el contenido del método print() sobre un archivo. OrtizOL.
def generador_fibonacci():
fib1 = 0
fib2 = 1
while True:
yield fib2
fib1, fib2 = fib2, fib1 + fib2
with open('fibonaccis.txt', 'w') as f:
contador = 1
for fib in generador_fibonacci():
print('{}'.format(fib), file=f)
if contador == 10:
break
contador += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment