Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Idan shami
Idan shami
13,251 Points

little project(python)

I wanted to start a little project(very little) in python, to see if I learned something. Unfortunately, I didn't succeed so much.... I wanted to convert letters into signs( | , $...), I converted the letters into signs, but my problem was that no matter what order I wrote the letters, the order didn't change..... so here is my code

def translate():
    strange_list = []
    strange_ch = {"a": "|", "b": "*", "c": "$"}
    while True:
        strange_input = input("write your sentence: ")
        if strange_input == "QUIT":
            break
        else:
            for key, value in strange_ch.items():
                if key in strange_input:
                    strange_list.append(value)

    print(''.join(strange_list))

The order is always |*$ do I need to change the whole code, a bit, or write a bit on top of it? am I even allowed to ask it? (:

Thanks anyway.

Idan.

2 Answers

Tate Price
PLUS
Tate Price
Courses Plus Student 9,987 Points

I copied your code and it is not actually returning anything when I input a sentence.

Idan shami
Idan shami
13,251 Points

Write translate() in the last line

Tate Price
PLUS
Tate Price
Courses Plus Student 9,987 Points

I did call the function, but it didn't give me an output, even I have an input. I'll try to look at it some more, I was in a hurry yesterday.

Idan shami
Idan shami
13,251 Points

after you write the sentence you need to enter "QUIT" in upper case letters...

if strange_input == "QUIT":
    break

also, I noticed that if I write the letters separately one after another it does show me the order I gave. but if I write all of them in one line it doesn't.