Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

count the frequency of words in a file

from collections import Counter
def word_count(fname):
        with open(fname) as f:
                return Counter(f.read().split())

print("Number of words in the file :",word_count("test.txt"))
Comment

PREVIOUS NEXT
Code Example
Shell :: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease 
Shell :: create a docker-compose symbolic link to /usr/bin 
Shell :: install cluster for jupyter on ubuntu 
Shell :: keyboard shortcut paste gnome-terminal 
Shell :: laravel mix Uncaught ReferenceError: babelHelpers is not defined 
Shell :: webtorrent cli how to take Quality output 
Shell :: git log only folder 
Shell :: Rclone initial commit to remote drive 
Shell :: git revert a set of commits 
Shell :: docker Unable to setup unix socket lock file 
Shell :: how to print the number of columns in your terminal using tput in linux 
Shell :: debian 10 gcc compile 
Shell :: view shell variables 
Shell :: install using kartik extention 
Shell :: how do confirm a commit revert git 
Shell :: no module named typedefs pyinstaller 
Shell :: dnstwist kali linux 
Shell :: NOPASSWD 
Shell :: grub file path 
Shell :: verify in core compressor with swap backend VM_PAGER_COMPRESSOR_WITH_SWAP 
Shell :: how to make a log of my ternminal history 
Shell :: all sudo commands in ubuntu to be administrator 
Shell :: how to find the version of apache server in pentest 
Shell :: pip install pywikihub 
Shell :: nginx error ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist 
Shell :: repeat characters for line vim 
Shell :: rename files with sequential numbers linux 
Shell :: Bitbucket config to deploy aws instance 
Shell :: mac run a shell script 
Shell :: imagemagick visual diff pdf 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =