Neue Sprache
Python Beginner
Da ich schon fast ein Jahr nichts mehr geschrieben habe.
Bald Geburtstag ist und ich nicht Schlafen kann.
Habe ich den Entschluss gefasst mich um Python zu kümmern,
Kategorie Da ich schon fast ein Jahr nichts mehr geschrieben habe.
Bald Geburtstag ist und ich nicht Schlafen kann.
Habe ich den Entschluss gefasst mich um Python zu kümmern,
Hier meine ersten Gehrversuche:
name = raw_input('Enter file:')
handle = open(name,'r')
text = handle.read()
words = text.split();
counts = dict()
bigcount = None
bigword = None
for word in words:
counts[word] = counts.get(word,0) + 1
if bigcount is None or bigcount < counts[word]:
bigcount = counts[word]
print ''
bigcount = None
bigword = None
for word,count in counts.items():
if bigcount is None or count > bigcount:
bigword = word
bigcount = count
print bigword,bigcount
print bigword,bigcount
Kein Kommtentar!!!
Gruß JJR
name = raw_input('Enter file:')
handle = open(name,'r')
text = handle.read()
words = text.split();
counts = dict()
bigcount = None
bigword = None
for word in words:
counts[word] = counts.get(word,0) + 1
if bigcount is None or bigcount < counts[word]:
bigcount = counts[word]
print ''
bigcount = None
bigword = None
for word,count in counts.items():
if bigcount is None or count > bigcount:
bigword = word
bigcount = count
print bigword,bigcount
print bigword,bigcount
Kein Kommtentar!!!
Gruß JJR