Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Letter Frequency Counting

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Letter Frequency Counting. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Write a program to count how many times each letter repeats, then display each letter with its count in alphabetical order. Treat uppercase and lowercase letters as the same, and ignore non-letter characters. Implement def count_letters(text):; accept a string and return a list of [letter, count] pairs containing only letters that occur, ordered alphabetically.

Constraints

  • 0 <= len(text) <= 1000
  • The input may contain uppercase letters, lowercase letters, digits, spaces, and punctuation
  • Only alphabetic characters are included in the result
  • Letter matching is case-insensitive
  • Return letters in alphabetical order

Function Signature

def count_letters(text):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output