avatar Bite 286. Decompress

Write a function, called decompress(), that accepts a string and a dictionary as input.

The dictionary maps special character strings to sequences of characters.

The function goes through the argument string and if the character is in the dictionary, it converts it to the corresponding character sequence.  


>>> table = {'$': 's',

             '%': 'y',

             '/': 't'


>>> decompress('P%Bi/e$', table) 

Note that a special character may map to a sequence of characters that ALSO has a special character in it.  


>>> table = {'*': 'c',

             '#': '00',

             '$': '*y',


>>> decompress('$3#', table)

For example the symbol table maps $ to the string *y and * maps to c.

Login and get coding
go back Intermediate level
Bitecoin 3X

30 out of 31 users completed this Bite.
Will you be Pythonista #31 to crack this Bite?
Resolution time: ~22 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 4.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.8