❔ Help with Dictionary<string,string>

I have a series of textBoxes to enter strings like first name, last name etc. Each character of the string equals a key in a dictionary. I want to remove the keys and replace with values. Example string "Sally" , each character would be a key. I want to print the values. I can only use remove and insert methods.
4 Replies
mtreit
mtreit2y ago
Each character of a string being a dictionary key sounds like an odd setup, but just loop over each character in the string and do a lookup in your dictionary.
postReality
postReality2y ago
It is a homework scenario. thank you for the hint
notlyze
notlyze2y ago
@chowder Use a for loop to iterate over each character in the input string. For each character, use the dictionary's get() method to retrieve the corresponding value, and then use the remove() and insert() methods to replace the character with the value. Finally, print the modified string.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts