Skip to content

Commit 06b7c5e

Browse files
Merge pull request geekcomputers#142 from ELC/patch-1
Using String Formatting new format and list gens
2 parents 919b803 + 65e2522 commit 06b7c5e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

CountMillionCharacter.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,9 @@
292292

293293
wordlist = wordstring.split()
294294

295-
wordfreq = []
296-
for w in wordlist:
297-
wordfreq.append(wordlist.count(w))
295+
wordfreq = [wordlist.count(w) for w in wordlist]
298296

299-
print("String\n" + wordstring +"\n")
300-
print("List\n" + str(wordlist) + "\n")
301-
print("Frequencies\n" + str(wordfreq) + "\n")
302-
print("Pairs\n" + str(list(zip(wordlist, wordfreq))))
297+
print("String\n {} \n".format(wordstring))
298+
print("List\n {} \n".format(str(wordlist)))
299+
print("Frequencies\n {} \n".format(str(wordfreq)))
300+
print("Pairs\n {}".format(str(list(zip(wordlist, wordfreq)))))

0 commit comments

Comments
 (0)