Arranging and Presenting Data Using Dictionaries

Question

Geeting error in dictionaries with a unit test.

Sandbox URL

https://nt.dev/s/f6a5f2e115e2

Did you get a solution for this problem ??

I have the same error, the output is correct but the estructure is bad, I don’t know why is bad :frowning:

Hey Mritunjay,

Thanks for reaching out! The issue here is that your function is printing a instead of returning a. If you change this and print out sentence_analyzer("Pythonn"), the checks should pass.

You code should look something like this:

Solution
def sentence_analyzer(str):
    a = {}
    for keys in str:
        if keys == ' ':
            continue
        a[keys] = a.get(keys, 0) + 1
    return a

print(sentence_analyzer("Pythonn"))

Let me know if you have any questions!

Best,
Lorraine