Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 6, 2020 02:09
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 parzibyte/dc06dda7081e47e6ed13f5043d16c348 to your computer and use it in GitHub Desktop.
Save parzibyte/dc06dda7081e47e6ed13f5043d16c348 to your computer and use it in GitHub Desktop.
"""
____ _____ _ _ _
| _ \ | __ \ (_) | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___|
__/ | __/ |
|___/ |___/
Blog: https://parzibyte.me/blog
Ayuda: https://parzibyte.me/blog/contrataciones-ayuda/
Contacto: https://parzibyte.me/blog/contacto/
Copyright (c) 2020 Luis Cabrera Benito
Licenciado bajo la licencia MIT
El texto de arriba debe ser incluido en cualquier redistribución
"""
archivo = "input.txt"
salida = "result.txt"
busqueda = input("Ingresa búsqueda: ")
lineas_escribir = []
with open(archivo, "r") as archivo_lectura:
numero_linea = 0
for linea in archivo_lectura:
numero_linea += 1
linea = linea.rstrip()
separado = linea.split(" ")
if busqueda in separado:
lineas_escribir.append(str(numero_linea) + " - " + linea)
with open(salida, "w") as archivo_salida:
for linea in lineas_escribir:
archivo_salida.write(linea + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment