Skip to content

Instantly share code, notes, and snippets.

@Ape
Last active October 12, 2015 12:49
Show Gist options
  • Save Ape/a8303f50b22ca234bfc4 to your computer and use it in GitHub Desktop.
Save Ape/a8303f50b22ca234bfc4 to your computer and use it in GitHub Desktop.
7_2.py
#!/usr/bin/env python3
import collections
print("Syötä viestin tekstirivejä. Lopeta syöttämällä tyhjä rivi.")
teksti = ""
while True:
syöte = input()
if syöte:
teksti += syöte
else:
break
lukumäärät = collections.Counter((x.lower() for x in teksti.split()))
for sana, lkm in sorted(lukumäärät.items()):
print("{} : {} kpl".format(sana, lkm))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment