Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Python 3 Write a function that takes a string argument. The function should create a dictionary. Iterate through the string and store the letter

For Python 3

Write a function that takes a string argument. The function should create a dictionary. Iterate through the string and store the letter frequency in the dictionary you created. The key will be the letter and the value will be the number of times the letter occurs in the word. Print the dictionary.

For example, calling the function with the string happy will print {'h': 1, 'a': 1, 'p': 2, 'y': 1}.

Using pneumonoultramicroscopicsilicovolcanoconiosis as an argument will print

{'p': 2, 'n': 4, 'e': 1, 'u': 2, 'm': 2, 'o': 9, 'l': 3, 't': 1, 'r': 2, 'a': 2, 'i': 6, 'c': 6, 's': 4, 'v': 1}.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions