Question
def frequency(text): Return value: A list (of integers): how often each letter of the alphabet appears in text Assumptions: o The standard English alphabet is
def frequency(text):
Return value: A list (of integers): how often each letter of the alphabet appears in text Assumptions: o The standard English alphabet is used: "abcdefghijklmnopqrstuvwxyz" o All strings will be entirely in lowercase, and only contain valid letters in the alphabet.
How it works: o Count how many times each letter in the alphabet occurs in the text.
Store all of these values in a list. This list should be returned in alphabetical order:
index 0 is the frequency of the letter "a" index 1 is the frequency of the letter "b" index 2 is the frequency of the letter "c" so on until the letter "z"
Notes: HINT: If you haven't written the tally() function yet. you should do that first.
Don't use list.index() or list.count() !
Examples:
frequency("abcd") [1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
frequency("zoosarecool") [1,0,1,0,1,0,0,0,0,0,0,1,0,0,4,0,0,1,1,0,0,0,0,0,0,1]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started