Please Help! How do I pull result from dictionary keys and values TRANSLATOR APP?

Hi there, I am incredibly new to MIT App Inventor as well as computational thinking.
I am sure there is an easy answer, but I have searched the forums and all the models I found were above the level I am at.
The concept for this code is simple; when the user types an english character(s) in the input_box, that corresponds with a key in the dictionary, the result_label should show the corresponding value, japanese character.
But I have tried so many different things!!! Please, I'm not sure what this code should look like or what I'm missing/ doing wrong... Please can someone help me?


This block works well with a dictionary:

https://ai2.appinventor.mit.edu/reference/blocks/text.html#replaceallmappings

the way i understand the app's function - your user enters an english letter and if it's found in the dictionary, the app displays the equivalent japanese code - otherwise the app displays "not found".
(you can't use "wrong" because you're not trying to guess something.
in fact, your app is really a lookup table - am i right? if this is the case you only need one dictionary or a one-level dictionary. (your image shows that your lookup table, which is THE dictionary you need is embedded in an outer dictionary. take it out from there and make it THE dicitonary to use.
then your program boils down to:

when button is clicked, if the input is found in the dictionary, show the translation, else show "not found".

you can everything in the when_button_clicked button - you can borrow some parts of your "result" function so you can test the input if it's good or not.

good luck.

I think you don't need that nested dictionary. Anyway, if you use it, you need the key path of them:

1 Like

Oh my gosh, thank you so much!
I need to know figure out how to make it read both capitalization and lowercase, but this has tremendously helpful.
Thank you!!!!!

try with this:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.