Advertisement
LinuxAIO

Ejercicio 9.11

Jun 24th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import sys
  2.  
  3. if len(sys.argv)!=2:
  4.     print("Parametros invalidos")
  5.     sys.exit(1)
  6.  
  7. nombre = sys.argv[1]
  8. contador = {}
  9.  
  10. archivo = open(nombre, "r", encoding="utf-8")
  11. for linea in archivo:
  12.     linea = linea.strip().lower()
  13.     palabras = linea.split()
  14.     for p in palabras:
  15.         if p in contador:
  16.             contador[p]+=1
  17.         else:
  18.             contador[p]=1
  19. archivo.close()
  20.  
  21. for clave in contador:
  22.     print("%s = %d" % (clave,contador[clave]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement