Use a hash table to store texting shortcuts and their definitions. For example, “lol” means “laugh out loud.” Use this hash table to decode a text message. Iterate through all the words in the text message input, and if any are found, replace them with their definitions. Return the decoded string.
Note: The exact number of texting shortcuts used in this answer is up to the individual, but at least a handful should be used to make the method usable.
```
def decodeTextMessage(message):
shortcuts = {}
shortcuts["lol"] = "laugh out loud"
shortcuts["tmi"] = "too much information"
shortcuts["4"] = "for"
shortcuts["4eva"] = "forever"
shortcuts["afaik"] = "as far as I know"
shortcuts["asap"] = "as soon as possible"
shortcuts["b4"] = "before"
shortcuts["bc"] = "because"
shortcuts["bf"] = "boyfriend"
shortcuts["brb"]="be right back"
shortcuts["cu"] = "see you"
shortcuts["dgaf"] = "don't give a *freak*"
shortcuts["dl"] = "down low"
shortcuts["rofl"] = "rolling on the floor laughing"
shortcuts["u"] = "you"
messageToReturn = ""
splits = message.split(" ")
for word in splits:
if word in shortcuts.keys():
messageToReturn += shortcuts[word]+" "
else:
messageToReturn += word+" "
#Remove the last space
messageToReturn = messageToReturn [:-1]
return messageToReturn
```
You might also like to view...
The disadvantage of downsampling is the loss of data, or ____.
a. lossiness b. dimness c. loudness d. none of the above
The ____ files are the source files used by Director when you are creating movies.
A. .fla B. .dir C. .dcr D. .swf
What element is used to configure a new paragraph?
a. new b. paragraph c. p d. div
Each active thread in a process has its own processor registers, data area, and resources.
Answer the following statement true (T) or false (F)