Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Technical Interview Prep: Python Basics Basic Python Let's Get Together

Allison Seim
Allison Seim
1,625 Points

how to lookup a character of a tuple string in a dictionary

join.py
def morse_code(word):
    morse_dict = {
        'a': 'dot-dash',
        'b': 'dash-dot-dot-dot',
        'c': 'dash-dot-dash-dot',
        'd': 'dash-dot-dot',
        'e': 'dot',
        'f': 'dot-dot-dash-dot',
        'g': 'dash-dash-dot',
        'h': 'dot-dot-dot-dot',
        'i': 'dot-dot',
        'j': 'dot-dash-dash-dash',
        'k': 'dash-dot-dash',
        'l': 'dot-dash-dot-dot',
        'm': 'dash-dash',
        'n': 'dash-dot',
        'o': 'dash-dash-dash',
        'p': 'dot-dash-dash-dot',
        'q': 'dash-dash-dot-dash',
        'r': 'dot-dash-dot',
        's': 'dot-dot-dot',
        't': 'dash',
        'u': 'dot-dot-dash',
        'v': 'dot-dot-dot-dash', 
        'w': 'dot-dash-dash',
        'y': 'dash-dot-dash-dash',
        'z': 'dash-dash-dot-dot'
    }
    a = list(word):



   # enter your code below

morse_code("govern")

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,622 Points

Hey Allison Seim, looking closer, morse_dict uses curly brackets { }, instead of parens ( ), which makes it a dict Rather than a tuple

You can look up a letter in the dict using morse_dict[char] where char is the letter to wish to look up.

More on dict in the docs.

You won’t need to call the morse_code function in your solution.

Post back if you need more help. Good luck!!!