From the course: Level Up: Python
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Count unique words - Python Tutorial
From the course: Level Up: Python
Count unique words
(game machine chimes) - Pretty much every modern word processor has a word count tool to count the total number of words in a document. For this challenge, we're going to take that tool one step further to practice both breaking down text and counting items. Your goal is to write a Python function that determines the number of unique words in a text file and counts how many times each word occurs. It should accept the path to a text file as the input argument, and then print the total number of words in the file, as well as the top 20 most frequently used words, and how many times each of them occurs. An example call to the function might look like this. Printing out a message with the total word count and a top 20 list. How you choose to format that output is really up to you. You should ignore case when considering if two words are the same or different, and for this challenge, we'll say that words can…
Contents
-
-
-
Find prime factors3m 11s
-
(Locked)
Identify a palindrome2m 48s
-
(Locked)
Sort a string3m 2s
-
(Locked)
Find all list items3m 12s
-
(Locked)
Play the waiting game2m 22s
-
(Locked)
Save a dictionary3m 13s
-
(Locked)
Schedule a function3m 16s
-
(Locked)
Send an email3m 12s
-
(Locked)
Simulate dice3m 16s
-
(Locked)
Count unique words3m 12s
-
(Locked)
Generate a password3m 59s
-
(Locked)
Merge CSV files3m 35s
-
(Locked)
Solve a sudoku4m 8s
-
(Locked)
Build a zip archive3m 43s
-
(Locked)
Download sequential files4m 2s
-