Question

Python code define a function car that takes 'swift' as a parameter function should count how...

Python code
define a function car that takes 'swift' as a parameter

function should count how many letters in the string
function should return a dictionary where key is lower case alpha caracter and value is the number of times that character appears in sentence.

ex- input- that big car is so expensive
output- 't':1, 'h':1, 'a':2, 'b':1, 'i':3,......

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def car(swift):
    d = {}
    for ch in swift:
        ch = ch.lower()
        if ch.isalpha():
            if ch not in d:
                d[ch] = 0
            d[ch] += 1
    return d


print(car("that big car is so expensive"))

Add a comment
Know the answer?
Add Answer to:
Python code define a function car that takes 'swift' as a parameter function should count how...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT