Advertisement
elcocodrilotito

linea mas larga

Nov 24th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #Diseñar una función que muestre por pantalla la línea más larga de un archivo
  2. def lineamaslarga(archivo):
  3.     fp=open(archivo)
  4.     linea=fp.readline()
  5.     a=len(linea)
  6.     c=linea
  7.     while linea:
  8.         linea=fp.readline()
  9.         b=len(linea)
  10.         if a<b:
  11.             a=b
  12.             c=linea
  13.     fp.close()
  14.     return c
  15. print(lineamaslarga("linea mas larga.txt"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement